Skip to content

Tui esc vuln - #119

Merged
fredbi merged 3 commits into
go-openapi:masterfrom
fredbi:tui-esc-vuln
Aug 17, 2026
Merged

fredbi merged 3 commits into
go-openapi:masterfrom
fredbi:tui-esc-vuln

Conversation

@fredbi

@fredbi fredbi commented Aug 17, 2026

Copy link
Copy Markdown
Member

Change type

Please select: 🆕 New feature or enhancement|🔧 Bug fix'|📃 Documentation update

Short description

Fixes

Full description

Checklist

  • I have signed all my commits with my name and email (see DCO. This does not require a PGP-signed commit
  • I have rebased and squashed my work, so only one commit remains
  • I have added tests to cover my changes.
  • I have properly enriched go doc comments in code.
  • I have properly documented any breaking change.

fredbi and others added 3 commits August 17, 2026 08:13
Everything the panes draw comes out of a repository somebody else wrote:
a file's contents, the names around it, and the diagnostics and validation
findings quoting all three. None of it was escaped on the way to the styling
layer, so an ESC in a file name or a finding was read by the operator's
terminal as a command rather than drawn.

A new safetext package encodes a control character as its Unicode picture,
replacing one rune with exactly one rune, so no line changes length and the
rune columns the viewer addresses syntax runs, diagnostic marks and clicks by
all still land where they should. It is applied at the seams every external
string passes through: fit (tree rows, source lines, syntax runs), the file
panel's title, relTo, notify, and the diagnostic and validation rows. Prose
the panes lay out themselves keeps its own line feeds and tabs, since neither
can command a terminal.

Two paths need nothing and now say so. The source viewer's body was already
covered, because bubbles/textarea drops every control rune when the buffer is
set; the renderer guards it anyway, since that is the widget's paste hygiene
rather than a promise to us. The spec pane is fed only serializer output, and
both JSON and YAML escape a control character rather than emit it - asserted
by a test instead of assumed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
Detection reads every comment group in a file, so a swagger:meta was always
found wherever it sat. The block itself was then taken from the file's package
doc regardless of where it had been found, and what that produced depended only
on whether the file happened to have one.

With a package doc, an unrelated comment was parsed as the meta block: an
ordinary sentence about the package could set the specification's title and
version while the authored block was dropped. With no package doc, there was
nothing to parse at all, and the nil comment group reached the origin recorder
for the info node - a nil dereference that aborted the whole scan. Only a
caller asking for provenance got that far, which is why genspec-tui hit it and
the library did not.

The group carrying the annotation is now the meta block, which is what
detectNodes already implied and what the classifier's own documentation
already claimed. A block in the package doc comment - the documented
placement, and what every fixture uses - is unaffected: that group is the one
carrying the annotation.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
@fredbi
fredbi merged commit 5e4cf04 into go-openapi:master Aug 17, 2026
29 checks passed
@fredbi
fredbi deleted the tui-esc-vuln branch August 17, 2026 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant