Repository navigation
fix(s3): refuse bucket names that are not valid IDs - #15210
Conversation
The S3 gateway created a bucket document for any name in the URI, and the bucket ID is a segment of each object's storage path. A bucket named `..` put new objects one level above the project's upload directory, and the S3 device also turns `\` into `/`, so `..\..\builds` reached another storage root. Create now refuses such names, and lookups treat an existing one as missing so no further object can be written through it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review complete. No issues found — approved ✅. This PR hardens the S3-compatible gateway by validating the
The validation follows the existing Appwrite ID rules, so no legitimate bucket created through the REST API is affected. Reviewed commit: 2295300 |
🟢 Tier S · Ready to merge
The S3 gateway now validates bucket IDs before creating bucket documents and before resolving existing buckets. The E2E test covers rejected path-like IDs, failed object writes through those names, and their absence from bucket listings.
📂 Walkthrough · 2
Reviewed |
Security rulesWARNING (2 new) — review signal only; does not fail the job.
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
What
The S3 gateway's CreateBucket (
PUT /v1/s3/<bucket>) stored whatever name the URI held as the bucket document$id.Database::createDocumentdoesn't run the UID check on$id, so names such as..or....were accepted.The bucket ID is a segment of every object's storage path (
Base::path():<root>/<bucketId>/<fileId>.<ext>), and the S3 device resolves..segments and turns\into/. So:.., a new object was written to<uploads>/<fileId>.<ext>, outsideapp-<project>/..\..\builds, it was written under a different storage rootThe object name was always a fresh unique ID, so an existing file couldn't be overwritten. Reads go through the file document's own
path, so another project's files couldn't be read either.Fix
createBucket()refuses a name that failsUIDand returns 400 without writing anything.bucket()treats an existing invalid name asNoSuchBucket, so a bucket created before this fix can't be used to write again.Test
S3CustomServerTest::testCreateBucketRefusesPathSegmentschecks..,....and..\..\builds. For each name, creating the bucket returns 400, putting an object through it returns 404, and the name is absent from ListBuckets afterwards.I watched it fail on the current
mainS3 module (PUT /v1/s3/..%2Freturned 200, expected 400) and pass with this change. Both runs were against a local stack.🤖 Generated with Claude Code