Skip to content

Fix stored XSS in uploads and compare, stop leaking password hashes - #47

Merged
cherriae merged 1 commit into
mainfrom
fix/security-review
Nov 11, 2026
Merged

cherriae merged 1 commit into
mainfrom
fix/security-review

Conversation

@cherriae

Copy link
Copy Markdown
Member

Summary

Security fixes from a security review. Each fix has a regression test in tests/test_security.py that fails on the old code.

  • Stored XSS through uploads. Profile pictures and team logos were served with whatever Content-Type the uploader sent, so a ".png" posted as text/html or SVG ran as a page on our domain. send_gridfs_file now serves only png/jpeg/gif with nosniff and falls back to the default image otherwise, and team_logo goes through it. Payloads already stored are neutralised too.
  • Password hashes leaked to teammates. The scouter join copied the whole user document, and /api/compare sends records to the browser, so any team member could read every teammate's password_hash and email. The join now keeps only _id, username and teamNumber.
  • XSS in compare. /api/compare returned scouting notes as text/html. It now returns application/json.

After merging: ask teammates to change their passwords, since the hashes were exposed.

Checklist

  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • This PR fixes an issue.
  • This PR adds something new (e.g. subsystem).
  • This PR is not a code change (e.g. README, typehinting, examples, refactoring, ...)

🤖 Generated with Claude Code

- Uploaded images keep the client's Content-Type, so a ".png" posted as
  text/html or SVG was served inline from our origin (profile pictures
  and team logos). send_gridfs_file now serves only png/jpeg/gif with
  nosniff and falls back to the default image otherwise; team_logo goes
  through it instead of its own copy. This also neutralises payloads
  already stored.
- SCOUTER_LOOKUP joined the scouter's whole user document, and
  /api/compare pushes $$ROOT to the browser, so every teammate's
  password_hash and email reached any team member. The lookup now
  projects only _id, username and teamNumber, for every pipeline that
  uses it.
- /api/compare returned a bare string, so Flask served scouting notes as
  text/html. It now sends application/json like its sibling endpoints.

Each fix has a regression test in tests/test_security.py that fails on
the old code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cherriae
cherriae merged commit 925c3c4 into main Nov 11, 2026
6 checks passed
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.

1 participant