Before submitting
- I searched the open and closed issues for a related report.
- I removed credentials, tokens, private paths, and sensitive target data.
Area
Native analysis or decompilation
Observed behavior
In inspect_windows_shortcut, targetPaths() orders target candidates by precedence: LinkInfo, RELATIVE_PATH, LinkTargetIDList, then EnvironmentVariableDataBlock. When a higher-precedence target cannot be read, observationsOf() uses walk.pathUncertainty to keep target_extension as null (and icon_location_differs_from_target from claiming true) instead of falling back to a lower-precedence path (as established in #12612 and #13653).
Three unread high-precedence cases do not set walk.pathUncertainty, so observationsOf() falls through to a lower-precedence LinkTargetIDList file entry (for example decoy.pdf) and reports a misleading target_extension: ".pdf":
HasLinkInfois set (0x00000002), andLinkInfocould not be read (linkInfo === null):parseLinkInfo()returnsnullwhen fewer than 8 bytes remain, whenLinkInfoSize < 0x1C, or whenLinkInfoSizeoverruns the file (or whenwalk.stoppedwas already set).walk.pathUncertaintystays allfalse.LinkInfodeclares Unicode offsets (LinkInfoHeaderSize >= 0x24), butLinkInfoSize < 0x24:parseLinkInfo()emitsmalformed_structureand computeshasUnicodeOffsets = false, leavinglocalUnicodeOffset = 0andsuffixUnicodeOffset = 0. UnlikeparseNetwork()(which setswalk.pathUncertainty.network ||= declaresUnicode && !unicode),parseLinkInfo()does not recorddeclaresUnicodeOffsets && !hasUnicodeOffsetsas uncertain.HasRelativePathis set (0x00000008), andRELATIVE_PATHcould not be read (stringData.relative_path === null): whenRELATIVE_PATH(or a precedingNAME_STRINGfield) is truncated,stringData.relative_pathstaysnullwithout marking target path uncertainty.
Reproduction
- Construct a Shell Link (
truncated-linkinfo.lnk, 108 bytes) withLinkFlags = HasLinkTargetIDList | HasLinkInfo | IsUnicode, anIDListcontaining a singlefile_entrynameddecoy.pdf, and a truncated 4-byteLinkInfoblock after theIDList. - Run:
rea inspect-windows-shortcut <path>/truncated-linkinfo.lnk --json - Observe exit code
0,coverage.status: "partial",link_info: null,issues: [{"code": "truncated", "offset": 104, "message": "LinkInfo is truncated"}], andobservationsreporting{"kind": "target_extension", "evidence_kind": "derived", "extension": ".pdf"}even though the declaredLinkInfotarget was never read.
The same fallback to .pdf reproduces on origin/main (a569ec558) when LinkInfoHeaderSize = 0x24 with LinkInfoSize = 0x1C, or when HasRelativePath is set and RELATIVE_PATH (or preceding NAME_STRING) is truncated.
Expected behavior
Under the same walk.pathUncertainty rule already used for unreadable LinkInfo string offsets, truncated CommonNetworkRelativeLink Unicode headers, and unreadable EnvironmentVariableDataBlock entries, any declared high-precedence target path (LinkInfo, its declared Unicode header offsets, or RELATIVE_PATH) that cannot be read must keep target_extension as null rather than falling through to a lower-precedence IDList entry.
Impact and scope
- Affects
inspect_windows_shortcut(CLI and MCP) on truncated or malformed.lnkfiles that pair anIDListdecoy filename with an unreadLinkInfo, truncated UnicodeLinkInfoheader, or unreadRELATIVE_PATH. - Reports a concrete
target_extensionfrom a lower-precedence field when the declared higher-precedence target is unknown.
REA version
6.10.1 (origin/main a569ec558; compiled CLI reproduced on ef21d8f40, parser tests reproduced on a569ec558)
Runtime and platform
Node.js v24.22.1; Windows x64
Target and artifact context
Synthetic Windows Shell Link (.lnk) fixtures (108 bytes for truncated LinkInfo, plus truncated Unicode LinkInfo header and truncated RELATIVE_PATH fixtures) with IDList file entry decoy.pdf
Interface
CLI
Earliest failure stage
Native analysis or reconstruction
Relevant output or evidence
Observed observations before fix on truncated-linkinfo.lnk (exit code 0):
{
"kind": "target_extension",
"evidence_kind": "derived",
"extension": ".pdf"
}Source references (src/native/windows/WindowsShortcutParser.ts on a569ec558):
parseLinkInfo(:912-997): checksdeclaresUnicodeOffsets && size >= LINK_INFO_UNICODE_HEADER_BYTESwithout settingwalk.pathUncertaintywhendeclaresUnicodeOffsets && !hasUnicodeOffsets, unlikeparseNetwork(:878-885).parseWindowsShortcut(:1408-1435): does not setwalk.pathUncertaintywhen(flags & 0x00000002) !== 0 && linkInfo === nullor when(flags & 0x00000008) !== 0 && stringData.relative_path === null.observationsOf(:526-561): derivestarget_extensionfromtargets[0]?.extension ?? nullwhenevertargetPathUnknownisfalse.
Typed outcome or recovery expected
coverage.status: "partial" with the existing truncated / block_size_overrun / malformed_structure issue, and observations reporting {"kind": "target_extension", "evidence_kind": "derived", "extension": null}.
Analysis or suspected cause
TargetPathUncertainty tracked unreadable inner LinkInfo offsets and unreadable EnvironmentVariableDataBlock entries, but omitted section-level unread LinkInfo, truncated LinkInfo Unicode header offsets, and unread RELATIVE_PATH.
Additional context
Related prior fixes establishing the walk.pathUncertainty invariant: #12612 and #13653.
Activity
0No activity yet.