Conversation
… - timing on loading
…terpreted as HTML Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…terpreted as HTML Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…terpreted as HTML Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Bugfix/ab#29960 fix null
…tion/Integrations/Chefs/FormsApiService.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ity.Theme.UX2/wwwroot/themes/ux2/table-utils.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…tion/Integrations/Endpoints/EndpointManagementAppService.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…gov/Unity into feature/AB#26441-DynamicUrls2
…tion/Integrations/Endpoints/EndpointManagementAppService.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…gov/Unity into feature/AB#26441-DynamicUrls2
Feature/ab#26441 dynamic urls2
feature/AB#26441-DynamicUrls-Sonar
This reverts commit 53d60da.
…-linking Feature/AB#23904 Select Type When Linking
…n-error AB#29825: Fix error on form configuration when FormSchema is empty string
feature/AB#26441-DynamicUrls-FixBaseUrl
| const linkElement = $(` | ||
| <div class="link-item ${linkTypeClass}${additionalClasses}"> | ||
| <div class="link-info"> | ||
| <span class="link-reference">${escapedReferenceNumber}</span> | ||
| <span class="link-applicant">${applicantDisplay}</span> | ||
| <span class="link-category">${categoryDisplay}</span> | ||
| <span class="application-status">${statusDisplay}</span> | ||
| ${statusBadges} | ||
| </div> | ||
| <span class="link-type-badge ${linkTypeClass}">${escapedLinkType}</span> | ||
| <button type="button" class="link-delete-btn" data-index="${index}" title="Delete Link"> | ||
| <i class="fa fa-times"></i> | ||
| </button> | ||
| </div> | ||
| `); |
Check warning
Code scanning / CodeQL
DOM text reinterpreted as HTML
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 months ago
To fix the problem, all user-controlled values that end up in HTML attributes or as HTML content must be safely sanitized or escaped. For CSS class names, it's best to restrict the allowed values to a hardcoded allowlist (whitelist) of valid identifiers—never insert unchecked user data into class attributes. For additional defense-in-depth, any unknown or untrusted class-names should be replaced with a safe fallback, or removed entirely.
Therefore:
- Change the logic generating
linkTypeClassto select only from a hardcoded list (i.e., known safe link types or a default). - Don't allow user input, or values derived from data sources like
$('#linkTypeSelect').val(), to directly influence raw HTML without validation. - For
linkTypeClassspecifically, implement an allowlist mapping logic at line 462.
No changes are required to the current escaping logic for the text/node content, as the rest of the user-supplied fields are escaped via escapeHtml.
All edits are confined to the file applications/Unity.GrantManager/src/Unity.GrantManager.Web/Views/Shared/Components/ApplicationLinksWidget/Default.js. Only lines involved in determining or using linkTypeClass need to be changed.
| @@ -459,7 +459,16 @@ | ||
| } | ||
|
|
||
| function createLinkElement(link, index, currentLinks, deletedLinks) { | ||
| const linkTypeClass = (link.linkType || 'related').toLowerCase(); | ||
| // Only allow safe predefined values for CSS class names to prevent XSS | ||
| const SAFE_LINK_TYPE_CLASSES = { | ||
| 'related': 'related', | ||
| 'parent': 'parent', | ||
| 'child': 'child', | ||
| 'dependency': 'dependency', | ||
| // Add other acceptable link types here as needed | ||
| }; | ||
| const rawLinkType = (link.linkType || 'related').toLowerCase(); | ||
| const linkTypeClass = SAFE_LINK_TYPE_CLASSES[rawLinkType] || 'related'; | ||
|
|
||
| // Ensure we have valid values, not undefined | ||
| const referenceNumber = link.referenceNumber || 'Unknown Reference'; |
No description provided.