Relationship Graph
View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0034432 | mantisbt | security | public | 2024-05-04 10:44 | 2024-05-12 15:39 |
| Reporter | unboundeduniverse | Assigned To | dregad | ||
| Priority | normal | Severity | major | Reproducibility | always |
| Status | closed | Resolution | fixed | ||
| Product Version | 2.26.1 | ||||
| Target Version | 2.26.2 | Fixed in Version | 2.26.2 | ||
| Summary | 0034432: CVE-2024-34081: Unsanitised custom field names printed | ||||
| Description | Improper escaping of a custom field's name allows an attacker to inject HTML and, if CSP settings permit, achieve execution of arbitrary JavaScript when:
https://github.com/mantisbt/mantisbt/security/advisories/GHSA-wgx7-jp56-65mq | ||||
| Steps To Reproduce | Create a custom field with some html in its name. | ||||
| Additional Information | To fix: bug_change_status_page.php
change to:
similar to 0027304 | ||||
| Tags | No tags attached. | ||||
|
I started some tests with such kind of custom fields. |
|
|
@unboundeduniverse Thanks for the report.
@atrol For now I have opened Advisory GHSA-wgx7-jp56-65mq and requested a CVE ID. |
|
|
@dregad my testing is completed. I had also a short look at the code, and found that we don't use only Please create a temporary private fork for the security advisory you created. If you want to have a very quick fix to get out 2.26.2 ASAP in combination with other security related fixes, it would be better if you start working on it. |
|
|
OK I will create the private fork. I also don't mind patching the security issue so we can release a hotfix ASAP if you have no time. I was just asking first, to avoid both of us making the same changes simultaneously. Just making sure I have not missed anything you may have found in your tests, here is what I have identified:
Right.
Any others ? |
|
|
Concerning
Wouldn't it be better to fix it on a lower level where the values are finally printed? i34432.patch (1,990 bytes)
From b7abf7a490019cbf6767eb79145a5fa2a4c1a138 Mon Sep 17 00:00:00 2001
From: Roland Becker <roland@atrol.de>
Date: Mon, 6 May 2024 17:36:50 +0200
Subject: [PATCH] Sanitize custom field names before printing
Fixes #34432
---
bug_change_status_page.php | 2 +-
core/print_api.php | 9 +++++----
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/bug_change_status_page.php b/bug_change_status_page.php
index 427850389..a771f2d6c 100644
--- a/bug_change_status_page.php
+++ b/bug_change_status_page.php
@@ -303,7 +303,7 @@ layout_page_begin();
<tr>
<th class="category">
<?php if( $t_require && $t_has_write_access ) {?><span class="required">*</span><?php } ?>
- <?php echo lang_get_defaulted( $t_def['name'] ) ?>
+ <?php echo string_attribute( lang_get_defaulted( $t_def['name'] ) ) ?>
</th>
<td>
<?php
diff --git a/core/print_api.php b/core/print_api.php
index c52bc3bf8..d7ec8947b 100644
--- a/core/print_api.php
+++ b/core/print_api.php
@@ -1492,17 +1492,18 @@ function print_bracket_link_prepared( $p_link ) {
* @return void
*/
function print_link( $p_link, $p_url_text, $p_new_window = false, $p_class = '' ) {
+ $t_url_text = string_attribute( $p_url_text );
if( is_blank( $p_link ) ) {
- echo $p_url_text;
+ echo $t_url_text;
} else {
$t_link = htmlspecialchars( $p_link );
if( $p_new_window === true ) {
- echo '<a class="new-window ' . $p_class . '" href="' . $t_link . '" target="_blank">' . $p_url_text . '</a>';
+ echo '<a class="new-window ' . $p_class . '" href="' . $t_link . '" target="_blank">' . $t_url_text . '</a>';
} else {
if( $p_class !== '' ) {
- echo '<a class="' . $p_class . '" href="' . $t_link . '">' . $p_url_text . '</a>';
+ echo '<a class="' . $p_class . '" href="' . $t_link . '">' . $t_url_text . '</a>';
} else {
- echo '<a href="' . $t_link . '">' . $p_url_text . '</a>';
+ echo '<a href="' . $t_link . '">' . $t_url_text . '</a>';
}
}
}
--
2.39.1.windows.1
|
|
You're probably right. I was concerned about those usages where print_link() is already given an escaped string, in which case we would get double encoding, e.g. But there are only 11 occurrences of print_link() calls so it should be quick to find and fix them if needed. |
|
Would be good if you could patch. |
|
|
Yes that is my Github username. |
|
|
Thanks for the feedback @unboundeduniverse. I have added you to the draft Advisory, so you can access the private repository with the fix. |
|
|
Just to add a bit of info: if the custom field is set to be required on update then it will appear for all status options when changing status, not just resolved and closed. This doesn't change the fix - it looks ok. |
|
|
They also should be sanitised in the excel export. excel_api.php change it to: |
|
|
Right, good point. I didn't bother testing Excel export as I was focused on HTML injection which is not applicable in this context. Follow-up in 0034441 |
|
|
MantisBT: master-2.26 447a521a 2024-05-06 13:04 Details Diff |
Proper escaping of Custom Field name for display Fixes XSS vulnerability on - bug_change_status_page.php (resolving and closing issues) - view_all_bug_page.php & print_all_bug_page.php (when the custom field is selected as a column for display/print) Fixes 0034432, CVE-2024-34081 |
Affected Issues 0034432, 0034442 |
|
| mod - bug_change_status_page.php | Diff File | ||
| mod - core/print_api.php | Diff File | ||
related to
child of
duplicate of