Function: isSafeArtifactPath()
isSafeArtifactPath(
candidate):boolean
Defined in: Data/Core/FeaturePackTypes.ts:191
Is candidate safe to join onto the pack root?
This is the single most security-relevant function in the feature-pack path:
it is what stands between a catalog entry and an arbitrary file write. It is
an allowlist by construction — each segment must match PATH_SEGMENT_RE —
rather than a blocklist of known-bad sequences, because the blocklist form of
this check is exactly the one that keeps getting bypassed (....//, UTF-8
overlong encodings, backslash-vs-slash on Windows, NTFS alternate data
streams).
Rejects: absolute paths, drive letters, UNC prefixes, backslashes, ./..
segments, empty segments, leading/trailing separators, control characters,
colons, trailing dots or spaces, and Windows reserved device names.
Parameters
candidate
string
Returns
boolean