🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

fix(site): replace ansi-to-html in the log viewer - #27206

Merged
aslilac merged 3 commits into
mainfrom
lilac/sec-266-cure53-cdm-02-004-redos-ansi-to-html
Jul 14, 2026
Merged

fix(site): replace ansi-to-html in the log viewer#27206
aslilac merged 3 commits into
mainfrom
lilac/sec-266-cure53-cdm-02-004-redos-ansi-to-html

Conversation

@aslilac

@aslilac aslilac commented Jul 13, 2026

Copy link
Copy Markdown
Member

Replaces the unmaintained ansi-to-html (last released ~5 years ago) with
fancy-ansi in the agent log
viewer, the library's only consumer. fancy-ansi parses in linear time and
escapes untrusted markup by default, resolving the ReDoS reported in Cure53
CDM-02-004 (SEC-266).

While here, the carriage-return progress-bar handling is simplified from a
regex split to lastIndexOf/slice, and the manual dangerouslySetInnerHTML
is dropped in favor of the library's <AnsiHtml> component.

The existing XSS-escaping test still passes, and a new Storybook story exercises
ANSI colors, carriage-return redraws, escaped markup, and the reported payload.

Implementation plan

Context

Cure53 CDM-02-004 (SEC-266, LOW): ReDoS in ansi-to-html@0.7.2.

Findings

  • Single call site: AgentLogLine.tsx (agent/startup logs). It was the only
    consumer of ansi-to-html.
  • The finding's "workspace build logs" label is inaccurate. The build-logs path
    (WorkspaceBuildLogs -> Logs) renders output as plain text with no ANSI
    conversion, so the real surface is agent logs.
  • escapeXML: true meant this was DoS-only (consistent with LOW).
  • line.output.split(/\r/g).pop() bounded input but did not prevent the hang.

Decision

Two independent workstreams, one PR at a time:

  1. This PR: swap ansi-to-html -> fancy-ansi.
  2. Follow-up spike (not gated by the security ticket): a headless ghostty-web
    parser prototype as a proving ground for the planned xterm.js ->
    ghostty-web migration.

Verification

  • fancy-ansi.toHtml on the reported payload: linear time (50k chars ~0.1ms).
  • XSS input is escaped, not rendered.
  • biome, tsc, knip, unit test, and Storybook story tests pass.

Generated by Coder Agents on behalf of @aslilac.

ansi-to-html 0.7.2 (unmaintained) has a ReDoS in its SGR regex
(Cure53 CDM-02-004 / SEC-266). The agent log viewer is the only
consumer. Swap it for fancy-ansi, which parses in linear time and
escapes untrusted markup by default.

Also simplify the carriage-return progress-bar handling from a regex
split to lastIndexOf/slice.
@linear-code

linear-code Bot commented Jul 13, 2026

Copy link
Copy Markdown

SEC-266

…p useMemo

Move the ANSI/ReDoS/carriage-return coverage into the vitest suite instead
of a Storybook story, since it is purely functional. Also drop the useMemo
around the carriage-return slice.
…tory

Keep the visual AnsiFormatting story for presentation while the functional
assertions live in the vitest suite.
@aslilac
aslilac merged commit b377bec into main Jul 14, 2026
26 of 27 checks passed
@aslilac
aslilac deleted the lilac/sec-266-cure53-cdm-02-004-redos-ansi-to-html branch July 14, 2026 18:54
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants