Repository navigation
Fix five high-severity security findings; add crop-before-upload for lotto photos - #40
Merged
Merged
Conversation
1. Registration is closed unless ALLOW_REGISTRATION=True (register form, POST /auth/register and first-time Google/GitHub sign-in). Passwords need 8+ characters; missing fields, duplicate emails and non-JSON bodies get a 400 instead of a 500, and the register form no longer crashes on errors. 2. Todo routes check ownership: update_todo, delete_todo, mark_done, mark_status and exec_rules act only for the owner or an admin. The username or id in the request is no longer trusted. 3. Admin actions that change filtering are POST-only (rules_toggle enable/disable, stop/enable traffic, delete_block, auto_push, auto_import), so an <img> in a blog post or a link can't fire them. State-changing requests whose Origin/Referer names another host are refused. 4. Note media is rendered inline only for image (not SVG), audio and video types; everything else is sent as a download, with nosniff. An uploaded HTML file can no longer run script with the viewer's login. 5. /auth/callback returns text/plain, so its code parameter can't inject script. All responses now carry X-Content-Type-Options: nosniff. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012k19dCKBK4J2UdDMJd5gLv
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9d2f8c514f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Origin: null (sandboxed frames and other opaque origins) parsed to an empty host and was let through, also skipping the Referer fallback. Any Origin or Referer that doesn't name our own host is now refused; requests with neither header still pass. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012k19dCKBK4J2UdDMJd5gLv
A tray photo usually includes the edge of neighbouring trays, whose tickets would be counted twice. After choosing photos, each one now shows a preview with a crop frame: drag to draw it, drag inside to move, drag a corner to resize, "Use whole photo" to reset. On upload, framed photos are replaced by a JPEG of just that region cut from the full-resolution image (capped at 16 MP for the iOS canvas limit); unframed photos are uploaded untouched. Runs entirely in the browser after the existing HEIC conversion, so the server is unchanged. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012k19dCKBK4J2UdDMJd5gLv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR carries two separate changes on one branch: the security fixes (commits
9d2f8c5,489d23b) and a lotto upload feature (commita067199).Part 1: security fixes
Fixes the five high-severity findings from the security audit. Each was reproduced on a local instance (PostgreSQL) before the fix and re-tested after.
ALLOW_REGISTRATION=Trueopens it. Passwords need 8+ characters.update_todo,delete_todo,mark_done,mark_statusandexec_rulesact only for the owner or an admin<img>in a blog post could switch off filtering in the admin's browsernosniff./auth/callback?code=<script>…was reflected as HTMLtext/plainBehaviour changes to know before merging
POST /auth/registerand first-time Google/GitHub sign-in are refused; existing accounts log in as before. To add a family member, setALLOW_REGISTRATION=Truein.env, restart, let them sign up, then remove it. Documented in the README.userstable for any you don't recognise.Details
reject_cross_site_writesinapp.py): a POST/PUT/DELETE whoseOrigin(orReferer) does not name the request's own host is refused with 403, including hostless values such asOrigin: null. Requests with neither header (the mobile app, scripts) pass through, so the notesync API is unaffected. This complementsSameSite=Lax; it is not a per-form CSRF token.nosniff: every response now carriesX-Content-Type-Options: nosniff.test_mark_todo_status_success) had a user marking another user's task, which encoded the bug, so it now marks the user's own.Not in this PR
The medium and low findings from the audit:
~/.sshmountedPOST /logsSecureflagPart 2: crop before upload (lotto)
A photo of one tray usually catches the edge of the neighbouring trays, whose tickets would then be counted twice. The upload form on
/lottonow shows a preview of each chosen photo with a crop frame:Testing
pytest -q: 460 passed.ruff check .clean on 0.17.4.tests/test_security_fixes.pycovers each fix, including that legitimate use still works. Re-ran the audit's attack script against this branch on PostgreSQL:exec_rulesreturn 403application/octet-streamattachment/auth/callbackistext/plain🤖 Generated with Claude Code
https://claude.ai/code/session_012k19dCKBK4J2UdDMJd5gLv