Skip to content

fix(windows): floor LinkInfo string offsets at the mandatory header - #12403

Merged
morluto merged 1 commit into
mainfrom
fix/shortcut-linkinfo-header-floor
Nov 19, 2026
Merged

morluto merged 1 commit into
mainfrom
fix/shortcut-linkinfo-header-floor

Conversation

@morluto

@morluto morluto commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to #10416. That change bounded LinkInfo string offsets by the declared LinkInfoHeaderSize. A declared size below the mandatory 0x1C still let an offset inside the 28-byte header decode as a path. This floors those reads at max(HeaderSize, 0x1C).

Problem and expected behavior

LinkInfoHeaderSize is at least 0x1C (MS-SHLLINK §2.3). After #10416, the string floor was the declared size. With HeaderSize 0x10 and LocalBasePathOffset 0x14, the parser read header bytes as a path, treated that path as readable, and could derive an icon mismatch from it.

An offset inside the mandatory header is reported as malformed_structure at the offset field. The string stays null, so the existing path uncertainty leaves the target extension unknown and blocks a mismatch claim. The stored header_size stays the declared value. An offset exactly at 0x1C remains string data.

Change and scope

parseLinkInfo uses max(headerSize, LINK_INFO_FIXED_HEADER_BYTES) for the local path, common-path suffix, and their Unicode twins. Main's newer header rules stay in place: sizes other than 0x1C or at least 0x24 are still malformed, Unicode offsets are still read only when the declared header is at least 0x24 and the structure holds those fields, and a declared header of 0x1D through 0x23 still ends at that declared size so ANSI fields after it stay readable.

VolumeID and network blocks do not have this hole. A VolumeID shorter than 16 bytes, or a network block shorter than 20 bytes, is rejected before any string read. Their floors stay the fixed headers (16 or 20 for a volume label, 0x14 or 0x1C for a network name), not a declared size that can shrink the header. A network block that declares Unicode offsets but ends before 0x1C still uses the 0x14 floor, so an ANSI string after that fixed header can be read while the truncation issue stands.

Contribution scope: not applicable. This is an ordinary bounds fix in the existing Shell Link parser. No new provider, target execution, injection, mutation, or protection recovery.

Contract and boundary impact

  • Semantic owner and earliest changed stage: WindowsShortcutParser owns LinkInfo string reads and the derived target observations. The service, CLI, and MCP consume that report unchanged. No parser path was removed.
  • Contribution scope fit and linked maintainer decision: not applicable.
  • CLI and MCP/tool-catalog contract: same inspect_windows_shortcut operation. A too-small LinkInfoHeaderSize now yields a null string, malformed_structure at the offset field, partial coverage, and unknown extension or mismatch when that path was required.
  • Provider, bridge, target-format, or platform compatibility: Shell Link bytes only. No provider or bridge change.
  • Evidence, artifact, provenance, or reconstruction contract: artifact identity is unchanged. The declared header size is preserved. An unreadable path stays unknown rather than becoming header bytes.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable. Read-only parse of caller-selected bytes.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): none.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: WindowsShortcutParser.test.ts plants C:\x at LinkInfo offset 0x14 with HeaderSize 0x10 for the local path and the common-path suffix. Each case expects malformed_structure at that offset field, a null string, partial coverage, a null icon comparison, and a null target extension. A boundary case with the offset at 0x1C reads C:\ok.exe, does not report that field, matches the icon, and keeps extension .exe.
  • Base reproduction or other evidence: on current main, before this floor, HeaderSize 0x10 and offset 0x14 decode the planted bytes as a path. The new tests fail there and pass with the floor. Reserved sizes 0x1D through 0x23 are covered by the existing boundary suite, which still sees C:\Notes and report.txt.
  • User-visible CLI/MCP output (if applicable): not re-run. The parser and boundary tests cover the report fields the CLI and MCP return.
  • Remaining proof gaps: no live CLI or MCP session. VolumeID and network needed no code change; their existing header-offset tests still pass inside the parser suite.

For boundary fixes, identify the applicable boundary regressions
and lifecycle regressions
covered by the evidence above, and explain relevant gaps.

Malformed-input coverage: undersized LinkInfoHeaderSize with an in-header string offset, and the 0x1C boundary where the string is still data. Lifecycle regressions are not applicable; the parser does not own a process or session.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npx oxfmt on docs/guides/native/windows-shortcut.md, src/native/windows/WindowsShortcutParser.ts, and src/native/windows/WindowsShortcutParser.test.ts — completed, Node v24.22.1.
  • npm run check:fast — typecheck and lint succeeded; architecture guards passed across 2898 source files.
  • npm run test:focused -- src/native/windows/WindowsShortcutParser.test.ts — 91 passed.
  • npm run test:focused -- tests/boundary/filesystem/windowsShortcut.test.ts — 26 passed, including reserved LinkInfoHeaderSize values 0x1D through 0x23.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Shortcuts whose LinkInfoHeaderSize is at least 0x1C keep the same string reads. A declared size below 0x1C no longer reports header bytes as a path.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable. Synthetic Shell Link bytes only.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: local read of a caller-selected shortcut. No new authority.

Author readiness

Human owner: @morluto

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.
Open in Web Open in Cursor 

A LinkInfoHeaderSize below 0x1C no longer lowers the string-offset floor.
Reserved 0x1D..0x23 headers still end at their declared size, so ANSI
fields after that header stay readable.

Co-authored-by: morluto <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T15:28:58.967300Z 742913f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

This PR stops the Windows shortcut reader from treating mandatory header bytes as path text when the stored header size is too small.

  • LinkInfo paths stay outside the mandatory header.

Validation was source-based; tests were not rerun.

Reviews (1) · Last reviewed commit: "fix(windows): floor LinkInfo string offs..." · Reviewed by Greptile

@morluto
morluto merged commit 6a5d77b into main Nov 19, 2026
40 checks passed
@morluto
morluto deleted the fix/shortcut-linkinfo-header-floor branch November 19, 2026 15:35
@morluto morluto added bug Something isn't working area: runtime Process capture and runtime observation labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants