Skip to content

fix(ui): guard leading tab and CR in escapeCsvCell against formula injection#7452

Closed
jaytbarimbao-collab wants to merge 1 commit into
JSONbored:mainfrom
jaytbarimbao-collab:ui-csv-guard-7439
Closed

fix(ui): guard leading tab and CR in escapeCsvCell against formula injection#7452
jaytbarimbao-collab wants to merge 1 commit into
JSONbored:mainfrom
jaytbarimbao-collab:ui-csv-guard-7439

Conversation

@jaytbarimbao-collab

Copy link
Copy Markdown
Contributor

Summary

escapeCsvCell (apps/loopover-ui/src/lib/csv-export.ts) guards spreadsheet formula-injection by prefixing ' when a value starts with =, +, -, or @. But a leading TAB (\t) or CR (\r) is also a formula-injection vector: a spreadsheet strips the leading whitespace and still evaluates the =/+/-/@ formula that follows, so a telemetry-sourced value like "\t=HYPERLINK(\"evil\")" slipped past the guard unescaped.

Fix

Extend the guard regex from /^[=+\-@]/ to /^[=+\-@\t\r]/, so a leading tab or CR is guarded the same way. No other behavior changes — RFC-4180 quoting is unchanged (a \r value still additionally quotes as before).

Verification

csv-export.test.ts gains a #7439 case asserting "\t=1+1""'\t=1+1", "\t@SUM(A1)""'\t@SUM(A1)", "\r=1+1" → quoted-and-guarded, and that a plain value is untouched. All 7 csv-export tests pass.

Closes #7439

…jection

escapeCsvCell only prefixed the anti-formula "'" when a value started with
=, +, -, or @. A spreadsheet strips a leading TAB (\t) or CR (\r) and still
evaluates the formula that follows, so a telemetry-sourced value like
"\t=HYPERLINK(...)" slipped past the guard unescaped. Extend the guard regex
to /^[=+\-@\t\r]/ so a leading tab or CR is guarded the same way.

Closes JSONbored#7439
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@github-actions
github-actions Bot had a problem deploying to preview/pr-7452 July 20, 2026 10:56 Failure
@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 20, 2026
@loopover-orb

loopover-orb Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Caution

🛑 LoopOver review result - fixes required

Review updated: 2026-07-20 11:02:49 UTC

2 files · 1 AI reviewer · no blockers · CI failing · blocked

🛑 Suggested Action - Fix Blockers

Review summary
This narrowly extends the existing formula-injection guard regex from /^[=+\-@​]/ to /^[=+\-@​\t\r]/ so a leading TAB or CR followed by a formula character is also single-quote-prefixed, closing the bypass described in #7439. I traced the two new assertions by hand: "\t=1+1" guards to "'\t=1+1" (no quoting needed since guarded string has no comma/newline/quote), and "\r=1+1" guards to "'\r=1+1" then gets RFC-4180 quoted because the CR is still present in the guarded string, producing "'\r=1+1" — both match the test expectations exactly. The change is minimal, correctly scoped, and the new test covers both the tab and CR branches plus a plain-value regression check.

Nits — 4 non-blocking
  • The inline comment in csv-export.ts:3-5 is a bit verbose for a one-line regex change; a single sentence would suffice.
  • Consider also asserting escapeCsvCell("\t-cmd") and a leading \t/\r with no following formula char (e.g. "\tplain") to fully exercise the new character-class branches rather than only = and @​ cases.
  • No functional changes needed; the fix and tests are correct as written.
  • If other formula-injection whitespace vectors exist in spreadsheet software (e.g. leading vertical-tab or form-feed), worth confirming with the linked issue whether those are in scope, otherwise this fully closes fix(ui): CSV export formula-injection guard doesn't cover leading tab/CR, only =+-@ #7439 as described.

CI checks failing

  • validate
  • validate-code

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #7439
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 172 registered-repo PR(s), 85 merged, 14 issue(s).
Contributor context ✅ Confirmed Gittensor contributor jaytbarimbao-collab; Gittensor profile; 172 PR(s), 14 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The regex is updated exactly as specified from /^[=+\-@​]/ to /^[=+\-@​\t\r]/, and new tests cover leading tab and CR cases asserting the same '-prefix guard, matching both requirements in the issue.

Review context
  • Author: jaytbarimbao-collab
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Rust
  • Official Gittensor activity: 172 PR(s), 14 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask <question> answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat <question> answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb

loopover-orb Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

LoopOver is closing this pull request on the maintainer's behalf (CI is failing (validate, validate-code)). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed.

@loopover-orb loopover-orb Bot closed this Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(ui): CSV export formula-injection guard doesn't cover leading tab/CR, only =+-@

1 participant