veracode

How to fix “Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)” in PHP output string

别说谁变了你拦得住时间么 提交于 2019-12-08 04:14:20
I have the following php code <?php $Output = '<table><thead><tr>'; $Output .= '<th>Display</th></tr></thead><tbody>'; for ($k = 0; $k < count($ColumnsInSQL); $k++) { $Output .= '<tr><td>'.$KS_ResultSet_level[$k][strtoupper(trim($ColumnsInSQL[$k]))].'</td></tr>'; } $Output .= '</tbody></table>'; echo $Output; ?> Recently I run the code in Veracode and I am getting issue with "echo $Output;" . Can anyone please help me to fix this? Use htmlentities() to encode special characters in the variable data. $Output .= '<tr><td>'.htmlentities($KS_ResultSet_level[$k][strtoupper(trim($ColumnsInSQL[$k]))]

Security: CWE-201: What is the correct way to securely read a properties file using openStream?

不打扰是莪最后的温柔 提交于 2019-12-07 17:10:45
问题 I'm working on coming up with a solution for CWE-201 that is flagged from Veracode. Background: CWE-201: Information Exposure Through Sent Data Information Exposure Through Sent Data Weakness ID: 201 (Weakness Variant) Status: Draft + Description Description Summary The accidental exposure of sensitive information through sent data refers to the transmission of data which are either sensitive in and of itself or useful in the further exploitation of the system through standard data channels.

Veracode directory traversal Issue c#

落爺英雄遲暮 提交于 2019-12-07 14:18:00
问题 I have this code that stores file to server: function void StoreFile(string inputFileName) { ... var extension = Path.GetExtension(inputFileName); if(extension == ".csv") { var fileName = string.Format("{0}_{1}{2}", Session.SessionID, new Guid(), extension); var dataFileServerPath = _documentService.getPath(fileName, UserProfile.UserName, UserProfile.SourceID); if(!string.IsNullOrEmpty(dataFileServerPath)) { try { using(FileStream dataFile = new FileStream(dataFileServerPath, FileMode.Create)

Veracode directory traversal Issue c#

寵の児 提交于 2019-12-05 18:45:31
I have this code that stores file to server: function void StoreFile(string inputFileName) { ... var extension = Path.GetExtension(inputFileName); if(extension == ".csv") { var fileName = string.Format("{0}_{1}{2}", Session.SessionID, new Guid(), extension); var dataFileServerPath = _documentService.getPath(fileName, UserProfile.UserName, UserProfile.SourceID); if(!string.IsNullOrEmpty(dataFileServerPath)) { try { using(FileStream dataFile = new FileStream(dataFileServerPath, FileMode.Create)) { .... } } cathc(Exception e) { ... } } } else { throw new NotSupportedFormatError(); } } Aftrer

“Untrusted initialization” flaw - while creating SQL Connection

試著忘記壹切 提交于 2019-12-01 17:42:21
I have done the following... private static IDbConnectionProvider CreateSqlConnectionProvider(DbConfig dbConfig) { return new QcDbConnectionProvider(() => { SqlConnectionStringBuilder csBuilder = new SqlConnectionStringBuilder(); if (!string.IsNullOrEmpty(dbConfig.DataSource)) csBuilder.DataSource = dbConfig.DataSource; if (!string.IsNullOrEmpty(dbConfig.Database)) csBuilder.InitialCatalog = dbConfig.Database; . . . . return new SqlConnection(csBuilder.ConnectionString); }); } The client is using VERACODE tool for doing code analysis and the VERACODE has detected a flaw "Untrusted

How to configure the XML parser to disable external entity resolution in c#

感情迁移 提交于 2019-11-30 09:19:32
var xDoc = XDocument.Load(fileName); I am using above code in a function to load an XML file. Functionality wise its working fine but it is showing following Veracode Flaw after Veracode check. Description The product processes an XML document that can contain XML entities with URLs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. By default, the XML entity resolver will attempt to resolve and retrieve external references. If attacker-controlled XML can be submitted to one of these functions, then the

How to configure the XML parser to disable external entity resolution in c#

穿精又带淫゛_ 提交于 2019-11-29 13:58:22
问题 var xDoc = XDocument.Load(fileName); I am using above code in a function to load an XML file. Functionality wise its working fine but it is showing following Veracode Flaw after Veracode check. Description The product processes an XML document that can contain XML entities with URLs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. By default, the XML entity resolver will attempt to resolve and retrieve

How to fix Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS) with error message?

好久不见. 提交于 2019-11-29 08:01:40
We use web control adapter in our login page. Recently we run VeraCode on our web application. In following function, we got CWE80, Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS), on the line rev.ErrorMessage = msg; Following is the function in the WebControlAdapterExtender class. static public void WriteRegularExpressionValidator(HtmlTextWriter writer, RegularExpressionValidator rev, string className, string controlToValidate, string msg, string expression) { if (rev != null) { rev.CssClass = className; rev.ControlToValidate = controlToValidate; rev.ErrorMessage

How to fix “Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Response Splitting')”

故事扮演 提交于 2019-11-28 10:27:46
After running VeraCode, it reported a following error "Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Response Splitting')" in the following code fragment: protected override void InitializeCulture() { //If true then setup the ability to have a different culture loaded if (AppSettings.SelectLanguageVisibility) { //Create cookie variable and check to see if that cookie exists and set it if it does. HttpCookie languageCookie = new HttpCookie("LanguageCookie"); if (Request.Cookies["LanguageCookie"] != null) languageCookie = Request.Cookies["LanguageCookie"]; //Check to see if

How to fix Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS) with error message?

巧了我就是萌 提交于 2019-11-28 01:30:51
问题 We use web control adapter in our login page. Recently we run VeraCode on our web application. In following function, we got CWE80, Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS), on the line rev.ErrorMessage = msg; Following is the function in the WebControlAdapterExtender class. static public void WriteRegularExpressionValidator(HtmlTextWriter writer, RegularExpressionValidator rev, string className, string controlToValidate, string msg, string expression) {