Repository navigation
fix(security): bounds on stored data and csv escaping - #111
Merged
Merged
Conversation
Findings SEC-13, SEC-14, SEC-15 of the backend code review. - Plan schema V1 caps amounts at 100_000, experts at 100 and lists at 500; CX ticker values must be finite. Out-of-range input is a 400, not a 500. - Empire state sync accepts known material tickers only, within +-1e9. - Planet insights skip stored plans with out-of-range amounts. - Preferences: locale, burnOrigin and visitation exclusions capped; planOverrides takes at most 500 UUID keys and drops plans the user doesn't own. At most 20 named versions per plan. - SafeCSVRenderer quotes text cells starting with = + - @ tab or CR in every CSV export. Spec: specs/2026-11-02-bcr-07-data-bounds-csv.md Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 23 |
| Duplication | 0 |
🟢 Coverage 100.00% diff coverage · +0.02% coverage variation
Metric Results Coverage variation ✅ +0.02% coverage variation (-1.00%) Diff coverage ✅ 100.00% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (4422433) 6809 6636 97.46% Head commit (fd7d3dd) 6856 (+47) 6683 (+47) 97.48% (+0.02%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#111) 70 70 100.00% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
…x/bcr-07-data-bounds-csv # Conflicts: # backend/tests/user/api/test_user_viewsets.py
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.
What and why
Plan amounts, CX prices, empire state totals and several preferences had no upper bound. Values no game can produce reached storage as 500s (int64 overflow, NaN on Postgres), poisoned planet insights and the public material tracker, and let preferences and named versions grow without limit. Plan names went into CSV exports unescaped, so a shared plan named
=1+1ran as a formula in another user's spreadsheet. Now out-of-range input is a 400 with field errors, and CSV cells are never formulas. Findings SEC-13, SEC-14, SEC-15 of the backend code review.Changes
locale≤16 chars,burnOrigin≤100, visitation exclusions ≤500 tickers.planOverridestakes at most 500 lowercase-UUID keys. Keys for plans the user doesn't own are dropped rather than rejected, because the frontend resends unsynced keys and a 400 would block every later preference save.SafeCSVRendererprefixes'to text cells starting with= + - @, tab or CR, in every CSV export. As a result, COGC---exports as'---.How it was verified
ruff check,ruff format --check,ty checkandpytestpass, before and after merging main."nan"→ 400. Unknown ticker → 400. Malformed planOverrides key → 400. 21st named version → 400.=1+1appears as'=1+1in both plan CSVs.maxLength,maxItems, ±1e9).origin/main(bcr-05 token revocation), no conflicts.Backend only, no migration, no frontend change needed.
🤖 Generated with Claude Code