Repository navigation
fix(windows): floor LinkInfo string offsets at the mandatory header - #12403
Merged
Merged
Conversation
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]>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryThis PR stops the Windows shortcut reader from treating mandatory header bytes as path text when the stored header size is too small.
Validation was source-based; tests were not rerun. Reviews (1) · Last reviewed commit: "fix(windows): floor LinkInfo string offs..." · Reviewed by Greptile |
6 of 22 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #10416. That change bounded LinkInfo string offsets by the declared
LinkInfoHeaderSize. A declared size below the mandatory0x1Cstill let an offset inside the 28-byte header decode as a path. This floors those reads atmax(HeaderSize, 0x1C).Problem and expected behavior
LinkInfoHeaderSizeis at least0x1C(MS-SHLLINK §2.3). After #10416, the string floor was the declared size. WithHeaderSize0x10andLocalBasePathOffset0x14, 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_structureat the offset field. The string stays null, so the existing path uncertainty leaves the target extension unknown and blocks a mismatch claim. The storedheader_sizestays the declared value. An offset exactly at0x1Cremains string data.Change and scope
parseLinkInfousesmax(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 than0x1Cor at least0x24are still malformed, Unicode offsets are still read only when the declared header is at least0x24and the structure holds those fields, and a declared header of0x1Dthrough0x23still 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,
0x14or0x1Cfor a network name), not a declared size that can shrink the header. A network block that declares Unicode offsets but ends before0x1Cstill uses the0x14floor, 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
WindowsShortcutParserowns LinkInfo string reads and the derived target observations. The service, CLI, and MCP consume that report unchanged. No parser path was removed.inspect_windows_shortcutoperation. A too-smallLinkInfoHeaderSizenow yields a null string,malformed_structureat the offset field, partial coverage, and unknown extension or mismatch when that path was required.docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs andskills/; 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.
Evidence and regression coverage
WindowsShortcutParser.test.tsplantsC:\xat LinkInfo offset0x14withHeaderSize0x10for the local path and the common-path suffix. Each case expectsmalformed_structureat that offset field, a null string, partial coverage, a null icon comparison, and a null target extension. A boundary case with the offset at0x1CreadsC:\ok.exe, does not report that field, matches the icon, and keeps extension.exe.HeaderSize0x10and offset0x14decode the planted bytes as a path. The new tests fail there and pass with the floor. Reserved sizes0x1Dthrough0x23are covered by the existing boundary suite, which still seesC:\Notesandreport.txt.For boundary fixes, identify the applicable boundary regressions
and lifecycle regressions
covered by the evidence above, and explain relevant gaps.
Malformed-input coverage: undersized
LinkInfoHeaderSizewith an in-header string offset, and the0x1Cboundary where the string is still data. Lifecycle regressions are not applicable; the parser does not own a process or session.For evidence-bearing changes:
Validation performed
npx oxfmtondocs/guides/native/windows-shortcut.md,src/native/windows/WindowsShortcutParser.ts, andsrc/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 reservedLinkInfoHeaderSizevalues0x1Dthrough0x23.Compatibility, safety, and release
LinkInfoHeaderSizeis at least0x1Ckeep the same string reads. A declared size below0x1Cno longer reports header bytes as a path.Author readiness
Human owner: @morluto
Before merge
type(scope): outcome.