Skip to content

feat(security): sanitize and cap user-pasted contract source before rendering in CodeViewer #472

Description

@luhrhenz

The problem

User-pasted contract source (up to 500,000 characters per lib/codeStore.ts) eventually gets rendered by components/CodeViewer.tsx. Depending on how that component renders (syntax highlighting libraries sometimes have their own HTML-generation paths), there's a real question of whether extremely large or specially-crafted source input could cause rendering performance problems or, in the worst case, any kind of injection issue — this needs to be verified, not assumed safe.

Why this is hard

Verifying this properly means understanding exactly how the syntax highlighter renders content (does it produce React elements safely, or does it ever touch dangerouslySetInnerHTML?) and stress-testing with pathological input (extremely long single lines, deeply nested comment-like structures, unusual Unicode) rather than just normal Rust source.

Direction

  • Audit CodeViewer.tsx and whatever syntax-highlighting mechanism it uses for any dangerouslySetInnerHTML or equivalent raw-HTML-insertion path
  • Stress-test rendering with pathological input (very long lines, unusual Unicode, adversarially crafted comment-like content) and fix any performance or rendering issues found
  • Add a rendering-side length/line-count guard independent of the storage-side cap in codeStore.ts, since a future change to that cap shouldn't silently remove this protection

Acceptance criteria

  • No raw-HTML-insertion path exists for user-controlled contract source, or its safety is explicitly verified and documented
  • Pathological input does not cause a rendering hang or crash

Relevant files: components/CodeViewer.tsx, lib/codeStore.ts


This is part of a deliberately hard "challenge" batch — the goal is a real rebuild/fix, not a cosmetic patch. Open a draft PR early and describe your approach before going deep.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26challengeDeliberately hard, in-depth rebuild/refactor challenge issuesecurity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions