Skip to content

fix: normalize object keys during bucket policy evaluation#2153

Merged
benmcclelland merged 1 commit into
mainfrom
sis/policy-key-normalization
May 28, 2026
Merged

fix: normalize object keys during bucket policy evaluation#2153
benmcclelland merged 1 commit into
mainfrom
sis/policy-key-normalization

Conversation

@niksis02
Copy link
Copy Markdown
Contributor

Object key validation allowed internal parent-directory segments such as public/../private.txt. Bucket policy and auth checks evaluated the raw key, so a policy allowing bucket/public/* could match the request while posix backend later resolved the key with filepath.Join and accessed bucket/private.txt.

Add backend-specific object key normalization to close that mismatch. The Backend interface now exposes NormalizeObjectKey so authorization can evaluate resources using the same key shape a backend will use for storage access.

Backends that do not collapse object paths, including Azure and the S3 proxy, inherit BackendUnsupported.NormalizeObjectKey. That implementation returns the input key unchanged, avoiding unnecessary normalization and keeping policy evaluation unpolluted for object stores where ../ is part of the key name.

posix/scoutfs normalize keys with filepath.Join so policy resources and request keys are compared after internal dot segments are collapsed.

Bucket policy evaluation now normalizes both the incoming object key and object resource patterns from the policy before matching. Object lock governance bypass policy checks use the same backend normalizer as well, so retention and legal hold authorization cannot diverge from backend path resolution.

@niksis02 niksis02 self-assigned this May 22, 2026
@niksis02 niksis02 force-pushed the sis/policy-key-normalization branch from a9c7ff3 to 21f81c0 Compare May 22, 2026 23:56
@niksis02 niksis02 requested a review from benmcclelland May 23, 2026 00:09
Comment thread backend/posix/posix.go Outdated
Comment thread auth/bucket_policy.go Outdated
@niksis02 niksis02 force-pushed the sis/policy-key-normalization branch from 21f81c0 to 56103fd Compare May 27, 2026 18:17
Object key validation allowed internal parent-directory segments such as `public/../private.txt`. Bucket policy and auth checks evaluated the raw key, so a policy allowing bucket/public/* could match the request while posix backend later resolved the key with `filepath.Join` and accessed `bucket/private.txt`.

Add backend-specific object key normalization to close that mismatch. The Backend interface now exposes `NormalizeObjectKey` so authorization can evaluate resources using the same key shape a backend will use for storage access.

Backends that do not collapse object paths, including Azure and the S3 proxy, inherit `BackendUnsupported.NormalizeObjectKey`. That implementation returns the input key unchanged, avoiding unnecessary normalization and keeping policy evaluation unpolluted for object stores where ../ is part of the key name.

posix/scoutfs normalize keys with filepath.Join so policy resources and request keys are compared after internal dot segments are collapsed.

Bucket policy evaluation now normalizes both the incoming object key and object resource patterns from the policy before matching. Object lock governance bypass policy checks use the same backend normalizer as well, so retention and legal hold authorization cannot diverge from backend path resolution.
@niksis02 niksis02 force-pushed the sis/policy-key-normalization branch from 56103fd to cd0b4e6 Compare May 27, 2026 18:20
@niksis02 niksis02 requested a review from benmcclelland May 27, 2026 18:37
@benmcclelland benmcclelland merged commit 2bc4da9 into main May 28, 2026
121 of 122 checks passed
@benmcclelland benmcclelland deleted the sis/policy-key-normalization branch May 28, 2026 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants