Skip to content

Comments

Report bug vulnerability analysis#109

Merged
LouisLetcher merged 17 commits intomainfrom
cursor/report-bug-vulnerability-analysis-1474
Feb 11, 2026
Merged

Report bug vulnerability analysis#109
LouisLetcher merged 17 commits intomainfrom
cursor/report-bug-vulnerability-analysis-1474

Conversation

@LouisLetcher
Copy link
Collaborator

@LouisLetcher LouisLetcher commented Feb 11, 2026

Summary

This PR addresses critical security vulnerabilities identified during a repository audit, focusing on preventing XSS, path traversal, and updating vulnerable dependencies.

Changes

  • HTML Reporting (src/reporting/html.py):
    • Implemented HTML escaping for all user-controlled content (symbols, strategies, parameters) interpolated into generated HTML reports.
    • Ensured JSON embedded in inline <script> tags is safely escaped to prevent XSS.
  • CLI Utilities (src/main.py):
    • package-run: Added robust validation for run_id to prevent path traversal attacks when creating archives.
    • clean-cache: Hardened directory traversal logic to prevent symlink escapes, ensuring files outside the intended cache root are not deleted.
  • Dependency Updates:
    • Bumped fastapi to 0.128.7 and added a direct starlette constraint to 0.52.1 in pyproject.toml and poetry.lock to resolve reported CVEs.
  • Tests: Added new unit tests to cover XSS protection in HTML reports and path traversal/symlink escape prevention in CLI commands.
  • No breaking changes.

How to Test

  1. Install dependencies: poetry install
  2. Run linters: poetry run ruff check . (should pass)
  3. Run tests: poetry run pytest (all tests, including new security tests, should pass)
  4. Audit dependencies: poetry run pip-audit (should report only pip itself as vulnerable, not application dependencies)
  5. Verify XSS protection:
    • Generate a report using a malicious symbol/strategy name (e.g., "<img src=x onerror=alert(1)>").
    • Open the generated report.html in a browser; the payload should be escaped and not execute.
  6. Verify package-run path traversal prevention:
    • Attempt poetry run main package-run ../../evil --reports-dir ./reports (should fail with a BadParameter error).
  7. Verify clean-cache symlink protection:
    • Create a symlink inside a cache directory pointing to a directory outside the cache root.
    • Place an old file inside the symlinked directory.
    • Run poetry run main clean-cache --max-age-days 7. The file outside the cache root (via symlink) should not be deleted.

Checklist (KISS)

  • Pre-commit passes locally (pre-commit run --all-files)
  • Tests added/updated where it makes sense (80% cov gate)
  • Docs/README updated if needed
  • No secrets committed; .env values are excluded
  • Backward compatibility considered (configs, CLI flags)

Related Issues/Links

  • Closes #
  • References #

Open in Cursor Open in Web


Note

Medium Risk
Touches security-sensitive areas (HTML generation and filesystem deletion/archiving) and upgrades core web dependencies, which could introduce behavior changes or edge-case regressions despite added tests.

Overview
Security hardening across reporting and CLI tooling. The HTML report generator now escapes all user-controlled fields and safely serializes JSON embedded in <script> tags to prevent XSS; it also supports fully-offline reports by writing plotly.min.js next to report.html (and exposes it as a downloadable artifact).

Filesystem traversal protections. package-run now validates run_id and enforces that resolved paths stay within reports_dir, and clean-cache now avoids following symlink directories/files and refuses deletions that resolve outside the cache root.

Infra/deps updates. Bumps fastapi (and adds/bumps direct starlette) and refreshes poetry.lock, updates the dashboard server UI to drop Tailwind CDN usage and link reports via the app’s download endpoint instead of file://, and hardens Docker builds by pinning/installing Poetry via pip, copying poetry.lock, creating a non-root user, and adjusting runtime PATH/env.

Written by Cursor Bugbot for commit c7557d8. This will update automatically on new commits. Configure here.

cursoragent and others added 3 commits February 10, 2026 20:49
Co-authored-by: Manuel H. <LouisLetcher@users.noreply.github.com>
Co-authored-by: Manuel H. <LouisLetcher@users.noreply.github.com>
Co-authored-by: Manuel H. <LouisLetcher@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 11, 2026 03:24
@cursor
Copy link

cursor bot commented Feb 11, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @LouisLetcher, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the security posture of the application by addressing several critical vulnerabilities. It introduces comprehensive HTML escaping to prevent Cross-Site Scripting (XSS) in generated reports, strengthens CLI commands against path traversal and symlink escape attacks, and updates core dependencies to resolve known Common Vulnerabilities and Exposures (CVEs). These changes collectively improve the application's resilience against various security threats.

Highlights

  • HTML Reporting Security: Implemented HTML escaping for all user-controlled content (symbols, strategies, parameters) and JSON embedded in inline scripts to prevent Cross-Site Scripting (XSS) vulnerabilities in generated reports.
  • CLI Security Enhancements: Added robust validation for run_id in the package-run command to prevent path traversal attacks and hardened the clean-cache command to prevent symlink escapes, ensuring files outside the intended cache root are not deleted.
  • Dependency Updates: Bumped fastapi to 0.128.7 and added a direct starlette constraint to 0.52.1 in pyproject.toml and poetry.lock to resolve reported CVEs.
  • New Security Tests: Added new unit tests to cover XSS protection in HTML reports and path traversal/symlink escape prevention in CLI commands, ensuring the new security measures function as intended.
Changelog
  • poetry.lock
    • Added 'annotated-doc' package.
    • Updated 'fastapi' version from '0.115.14' to '0.128.7' and its Python version requirement.
    • Updated 'starlette' version from '0.46.2' to '0.52.1' and its Python version requirement, also added 'typing-extensions' dependency.
    • Added 'typing-inspection' package.
    • Added platform markers for 'uvloop'.
    • Updated the content hash.
  • pyproject.toml
    • Updated 'fastapi' dependency version to '^0.128.7'.
    • Added 'starlette = "^0.52.1"' as a direct dependency.
  • src/main.py
    • Introduced a '_safe_segment' helper function to validate path segments, preventing path traversal.
    • Applied '_safe_segment' to 'run_id' in 'package_run' and added checks to ensure 'run_dir' is relative to 'reports_root'.
    • Modified 'clean_cache' to use 'os.walk' with 'followlinks=False' and added checks to prevent symlink escapes and ensure files are within the cache root before deletion.
    • Updated directory removal logic in 'clean_cache' to use 'os.walk' with 'topdown=False' and 'followlinks=False'.
  • src/reporting/html.py
    • Imported the 'html' standard library.
    • Added '_esc' function for HTML escaping of string values.
    • Added '_json_for_inline_script' function for safe embedding of JSON in '<script>' tags, escaping HTML-sensitive characters.
    • Applied '_esc' to various user-controlled fields (symbol, strategy, timeframe, metric, collection, params) when generating HTML table cells and card details.
    • Applied '_json_for_inline_script' to 'chart_json' and 'detail_json' to prevent XSS via inline script data.
    • Added 'escapeHtml' JavaScript function to the inline script to escape values in dynamically generated HTML elements.
  • tests/test_html_reporter.py
    • Added 'test_html_reporter_escapes_user_content' to verify that XSS payloads in user-controlled content are properly escaped in the generated HTML report.
  • tests/test_main_cli.py
    • Added 'test_package_run_rejects_path_traversal' to confirm that 'package-run' prevents path traversal attempts.
    • Added 'test_clean_cache_does_not_follow_symlink_dirs' to verify that 'clean-cache' does not delete files outside the cache root via symlinks.
Activity
  • No human activity (comments, reviews, etc.) has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively addresses several security vulnerabilities, including path traversal in CLI commands and Cross-Site Scripting (XSS) in HTML reports. The changes are well-implemented, with robust validation for user-supplied paths and comprehensive HTML escaping for dynamic content. The dependency updates to fastapi and starlette also resolve known CVEs. The addition of specific unit tests for these security fixes is a great practice and significantly increases confidence in the changes. My review includes a few suggestions to further improve code robustness and readability.

cursoragent and others added 7 commits February 11, 2026 03:27
Co-authored-by: Manuel H. <LouisLetcher@users.noreply.github.com>
Co-authored-by: Manuel H. <LouisLetcher@users.noreply.github.com>
Co-authored-by: Manuel H. <LouisLetcher@users.noreply.github.com>
Co-authored-by: Manuel H. <LouisLetcher@users.noreply.github.com>
Co-authored-by: Manuel H. <LouisLetcher@users.noreply.github.com>
Co-authored-by: Manuel H. <LouisLetcher@users.noreply.github.com>
Co-authored-by: Manuel H. <LouisLetcher@users.noreply.github.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Manuel H. <36189959+LouisLetcher@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 11, 2026 04:25
LouisLetcher and others added 2 commits February 11, 2026 05:25
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Manuel H. <36189959+LouisLetcher@users.noreply.github.com>
Co-authored-by: Manuel H. <LouisLetcher@users.noreply.github.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Signed-off-by: Manuel H. <36189959+LouisLetcher@users.noreply.github.com>
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

cursoragent and others added 3 commits February 11, 2026 10:44
Co-authored-by: Manuel H. <LouisLetcher@users.noreply.github.com>
Co-authored-by: Manuel H. <LouisLetcher@users.noreply.github.com>
Co-authored-by: Manuel H. <LouisLetcher@users.noreply.github.com>
@sonarqubecloud
Copy link

@LouisLetcher LouisLetcher merged commit c63d986 into main Feb 11, 2026
5 checks passed
@LouisLetcher LouisLetcher deleted the cursor/report-bug-vulnerability-analysis-1474 branch February 11, 2026 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants