Skip to content

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

Merged
JSONbored merged 1 commit into
JSONbored:mainfrom
jaytbarimbao-collab:ui-csv-guard-7439
Jul 20, 2026
Merged

fix(ui): guard leading tab and CR in escapeCsvCell against formula injection#7468
JSONbored merged 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

superagent-security Bot commented Jul 20, 2026

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-7468 July 20, 2026 11:07 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

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-20 13:56:43 UTC

2 files · 1 AI reviewer · no blockers · readiness 98/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This is a small, correct security hardening fix: it extends the formula-injection guard regex in escapeCsvCell to also cover leading TAB and CR characters, closing a real gap where a spreadsheet strips leading whitespace before evaluating a formula. The test additions directly exercise the new behavior (tab-prefixed formulas, CR-prefixed formula with quoting interaction, and an unchanged plain-value case), and the RFC-4180 quoting logic downstream is untouched and still correct since \r triggers the pre-existing needsQuotes check. The fix is applied at the correct layer (the single shared escapeCsvCell function used by toCsv) rather than patched at call sites.

Nits — 4 non-blocking
  • The verification claims 'All 7 csv-export tests pass' but the file shows 7 `it(...)` blocks across two `describe` blocks — worth double-checking the count language in the PR description is accurate, though this doesn't affect the code itself.
  • The inline comment in csv-export.ts (lines 3-5) is a bit long for what is a one-line regex change; could be tightened to a single line referencing fix(ui): CSV export formula-injection guard doesn't cover leading tab/CR, only =+-@ #7439.
  • Consider also guarding leading '|' (pipe) since some spreadsheet DDE-exploits use it as a fourth formula-trigger character in certain locales, though this is out of scope for this issue-linked fix.
  • The new test case's naming and structure match the existing 'guards formula-injection prefixes' test well — good consistency with existing conventions in apps/loopover-ui/src/lib/csv-export.test.ts.

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: 175 registered-repo PR(s), 85 merged, 14 issue(s).
Contributor context ✅ Confirmed Gittensor contributor jaytbarimbao-collab; Gittensor profile; 175 PR(s), 14 issue(s).
Improvement ✅ Minor risk: clean · value: minor
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: 175 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 added the manual-review Gittensor contributor context label Jul 20, 2026
@JSONbored
JSONbored merged commit bb07b8c into JSONbored:main Jul 20, 2026
9 checks passed
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. manual-review Gittensor contributor context

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 =+-@

2 participants