Repository navigation
ateapi: validate system-info projection paths at template creation - #1439
Taahir Ahmed (ahmedtd) merged 3 commits into
Conversation
This is good validation, but, just so I understand, did our use of os.Root already block any escapes using this? |
Yeah I believe the use of |
01a7b9b to
90a43d7
Compare
e34d997 to
850bfde
Compare
CreateActorTemplate accepted path traversal ("../escape") and absolute
paths ("/escaped") in ActorMetadataItem.path and TrustBundleDataSource.path,
and accepted several data sources projecting to the same path. atelet
rejects the former only when the actor starts, leaving it stuck in
RESUMING, and silently clobbers the latter.
Both path fields now require a clean relative Unix path, and the
data_sources list rejects any path that repeats or names a directory of
another projected path.
Fixes agent-substrate#1436
Fixes agent-substrate#1438
…ate check Move the system-info path rule into internal/volumepath so ateapi's template validation and atelet's pre-write check call one implementation instead of two that can drift. The rule splits on '/' and rejects empty, '.' and '..' segments, caps depth at 16 segments, and scans bytes rather than runes, rejecting only NUL so Unicode paths in any encoding pass. Track projected paths in a set for the cross-data-source duplicate check, mirroring the Kubernetes projected-volume validation, and drop the directory-prefix check.
850bfde to
a05ebf1
Compare
CreateActorTemplateaccepted../escapeand/escapedinActorMetadataItem.pathandTrustBundleDataSource.path, and accepted several data sources projecting to the same path. atelet only rejects the traversal at actor start, so the template is created but the golden actor sits inRESUMING. atelet never rejects duplicate paths at all: it writes the files in order and the last one wins.This PR moves both checks to template validation.
internal/volumepathpackage that both ateapi and atelet call, so the two cannot drift. It splits on/and rejects any segment that is empty,., or.., caps depth at 16 segments, and rejects NUL bytes. Any other byte is allowed, so Unicode paths pass.ActorMetadataItem.pathandTrustBundleDataSource.pathapply it through a+k8s:customValidationhook, and atelet'swriteSystemInfoFileapplies it again before touching the host filesystem.SystemInfoVolumeSource.data_sourcesgets a hook that tracks projected paths in a set and reports a duplicate on repeats, in the same shape as the Kubernetes projected-volume validation.The proto doc comment on
data_sourcesalso says at most oneactor_metadataentry may appear. Nothing enforces that, and this PR leaves it alone.New cases in
TestValidateSystemInfoVolumeSourceandTestValidateTrustBundleDataSourcecover the rejected shapes, andinternal/volumepathhas its own table test.hack/verify/codegen.shandhack/verify/golangci-lint.shpass.#1231 moves
writeSystemInfoFileintosysteminfovolume.goand ontoos.Root. Whichever PR lands second points that copy at the shared rule.Fixes #1436
Fixes #1438