fastapi - 💡(How to fix) Fix 🚨 Security Vulnerability Detected: docs/en/docs/js/custom.js [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
fastapi/fastapi#15322Fetched 2026-04-12 13:23:23
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Participants

Fix Action

Fix / Workaround

A patch is being generated and a PR will be linked shortly.

RAW_BUFFERClick to expand / collapse

Sentinel-Zero Automated Report

Issue: {"vulnerable": true, "type": "DOM-based XSS", "description": "The code uses node.textContent = inputCommands; which can lead to DOM-based XSS if the inputCommands variable contains user-controlled data. Additionally, the showRandomAnnouncement function uses children[index].style.display = 'block' which can also lead to DOM-based XSS if the children array contains user-controlled data."}

A patch is being generated and a PR will be linked shortly.

extent analysis

TL;DR

To mitigate the DOM-based XSS vulnerability, ensure that user-controlled data is properly sanitized before being assigned to node.textContent or used in the children array.

Guidance

  • Verify that the inputCommands variable contains only sanitized user input to prevent XSS attacks through node.textContent.
  • Review the showRandomAnnouncement function to ensure that the children array does not contain user-controlled data that could lead to DOM-based XSS.
  • Consider using a library or function to sanitize user input, such as encoding HTML entities, to prevent XSS vulnerabilities.
  • Inspect the code for any other instances where user-controlled data is used in a similar manner, as these may also be vulnerable to DOM-based XSS.

Example

// Sanitize user input using a function to encode HTML entities
function sanitizeInput(input) {
  return input.replace(/&/g, '&')
              .replace(/</g, '&lt;')
              .replace(/>/g, '&gt;')
              .replace(/"/g, '&quot;')
              .replace(/'/g, '&#039;');
}

// Use the sanitized input
node.textContent = sanitizeInput(inputCommands);

Notes

The provided guidance assumes that the inputCommands variable and the children array can contain user-controlled data. If this is not the case, or if additional context is needed, further review of the code may be necessary.

Recommendation

Apply workaround: Sanitize user-controlled data to prevent DOM-based XSS attacks, as a patch is being generated and may not be immediately available.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING