mirror of
https://github.com/rustfs/rustfs.git
synced 2026-12-01 05:34:41 +00:00
d620ecfa5fea099bd36844bcbfbbdff7a42332ef
137 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
5a0bdfcf1c |
fix(security): harden RPC, proxies, egress DNS, and OIDC (#9682)
* fix(security): harden RPC, proxies, egress DNS, and OIDC Harden internode RPC authentication/quotas, trusted-proxy allowlisting, protocol IAM policy conditions, outbound DNS egress pinning, and OIDC redirect and HTTPS enforcement: - Trusted proxies: replace broad private/link-local peer trust in simple mode with the configured trusted-proxy allowlist (defaulting to loopback-only) and update proxy integration coverage. - Protocol gateways & FTPS: populate standard IAM condition keys (SourceIp, SecureTransport, CurrentTime, EpochTime, UserAgent, Referer, principal metadata) in gateway authorization and replace the unchecked FTPS fallback IP parse with explicit connection context. - Bucket listing RPC: fail closed with entry index diagnostics instead of silently dropping malformed BucketInfo entries on encode/decode. - Internode RPC streams & replay cache: add framed HMAC-SHA256 response authentication with sequence/digest/EOF verification and post-verification endpoint pinning for read_file_stream and walk_dir, plus canonicalized per-peer entry and memory-budget replay cache isolation. - Outbound DNS egress: unify storage/tier, remote S3 replication targets, on-demand migration HTTP, Azure Blob, GCS, Keystone, and OIDC outbound checks onto OutboundPolicy and connection-time OutboundDnsResolver (with redirect blocking on Keystone) to stop DNS rebinding to loopback/link-local/metadata targets. - OIDC redirects & transport security: trust forwarded scheme/host only from verified trusted proxies, never reflect untrusted request headers into STS credential or logout redirects, and reject plaintext http:// OIDC URLs for non-loopback hosts unless explicitly opted in via RUSTFS_IDENTITY_OPENID_ALLOW_INSECURE_TRANSPORT. Refs: rustfs/backlog#1470, rustfs/backlog#1473, rustfs/backlog#1472, rustfs/backlog#1506 * fix(egress): restrict GCS endpoints and restore tier compatibility * ci: tighten the GCS error-format baseline * fix(ci): stop sending deprecated policy field in s3-tests add-user rustfs/rustfs#9677 hardened /rustfs/admin/v3/add-user to fail closed when a non-empty deprecated policy field is provided. scripts/s3-tests/run.sh was still passing policy=readwrite in the add-user body even though it immediately calls set-user-or-group-policy right after, and awscurl returned exit 0 on XML <Error> responses so provisioning silently failed and broke all alt-user s3-tests. Remove the deprecated policy field from the add-user payload, check awscurl responses for XML <Error> elements in provisioning, and add a regression unit test in scripts/s3-tests/test_runner_tools.py. Refs: rustfs/backlog#1246 * fix(ci): fail S3 user provisioning on HTTP errors without logging responses * fix(iceberg): reject repeated warehouses before validating bucket names * test(ecstore): wait for relaxed writes on the foreground lane * test(quota): isolate concurrent real-disk probes in CI * test(ecstore): scope upload lock identity helper to its Linux test * fix(oidc): preserve HTTPS in dynamic callbacks * ci: allow cold builds to finish all fuzz binaries |
||
|
|
365ef6d557 |
fix(swift): bound bodies, enforce quotas and default SSE/KMS authz (#9667)
Harden the Swift protocol layer across request body boundaries, storage quotas, FormPost redirects, and server-side encryption: - Bound control-plane and streaming request bodies at the HTTP frame and decompression boundaries (bulk-delete, bulk-extract tar/gzip/bzip2, FormPost multipart, SLO PUT) and cap bulk path/error/part/field counts. - Enforce MAX_OBJECT_SIZE for unknown-length and mismatched-length object uploads via a contract-safe streaming byte-cap reader, reject negative or malformed Content-Length headers, and enforce container byte/count quotas across PUT, bulk extract, FormPost, SLO, DLO, and COPY with serialized in-flight reservations and immediate usage-overlay updates. - Reject unauthenticated or expired FormPost requests with 401 without issuing a redirect, validate signed redirect schemes, restrict unsigned redirect_error targets to the signed redirect origin, and preserve binary upload payloads losslessly. - Honor bucket default SSE-S3/SSE-KMS on Swift writes (failing closed on unreadable encryption config or missing Content-Length) and authorize kms:Decrypt before DEK unwrap on Swift GET and COPY. - Fix an unconditional SessionContext import in dummy_storage.rs so rustfs-protocols compiles under both default and swift features. Refs: rustfs/backlog#1471, rustfs/backlog#1474, rustfs/backlog#1473, rustfs/backlog#2702 |
||
|
|
ed6f9cbdc4 | fix(authz,ecstore,protocols): harden S3 authz, WORM, storage & protocols (#9646) | ||
|
|
88a5d624d0 | refactor(protocols): bind multipart claims to protocol upload IDs | ||
|
|
496a34a6a7 |
chore(deps): drop hotpath shear ignore and refresh workspace deps (#9557)
* chore(shear): stop ignoring hotpath and clear shear findings Remove hotpath from cargo-shear ignored so feature-only usage is reported, drop unused deps found by shear --fix, delete empty access_owned stubs, and suppress false-positive unlinked paths for #[path] test modules. Co-Authored-By: qunjiazhu <qunjiazhu@gmail.com> Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> * chore(deps): refresh workspace deps and bump faster-hex to 2.0 Run cargo update and cargo upgrade for compatible requirements, including faster-hex 1.0.0 to 2.0.0. Existing hex_string/hex_decode call sites remain compatible. Co-Authored-By: qunjiazhu <qunjiazhu@gmail.com> Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> * fix(zstd): import seekable directly for security tests Use zstd_safe::seekable in the security test and document why the seekable dev-dependency stays: it enables the feature and must remain visible to cargo-shear as a real usage. Co-Authored-By: qunjiazhu <qunjiazhu@gmail.com> Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> * fix(admin): avoid private-bounds on S3Router test helper Move call_legacy to a free function so the pub(crate) OwnedOperation bound is not attached to a public inherent impl. Co-Authored-By: qunjiazhu <qunjiazhu@gmail.com> Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> * chore(deps): drop unused hotpath and demote rio md-5 to dev-deps Remove hotpath from crates that only feature-forward it with no source usage, keep rustfs-* hotpath feature links, make rio's hotpath optional for its cfg-gated measure_block!, and move rio md-5 to dev-dependencies. Co-Authored-By: qunjiazhu <qunjiazhu@gmail.com> Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> * chore(deps): refresh lockfile and bump arrow/jiff requirements Run cargo update, cargo upgrade, and cargo upgrade --incompatible. Bump arrow/parquet to 60.2.0 and jiff to 1.0.2. Co-Authored-By: qunjiazhu <qunjiazhu@gmail.com> Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> * fix(scanner): run service_cohort tests on a larger stack Linux libtest defaults to a 2 MiB test-thread stack; two-pool EC fixtures overflow it and abort. Run each service_cohort case on a dedicated 32 MiB thread, matching scoped_entry_fallback. Co-Authored-By: qunjiazhu <qunjiazhu@gmail.com> Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> * chore(deps): upgrade russh-sftp to 4.0 and refresh lockfile Run cargo update, cargo upgrade, and cargo upgrade --incompatible. Bump russh-sftp 3 to 4 (opaque SftpHandle wire type), plus lapin, hashbrown, and russh. Adapt the SFTP Handler and tests to SftpHandle. Co-Authored-By: qunjiazhu <qunjiazhu@gmail.com> Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> --------- Co-authored-by: qunjiazhu <qunjiazhu@gmail.com> Co-authored-by: heihutu <heihutu@gmail.com> Co-authored-by: zhi22915 <qiuzgang@gmail.com> Co-authored-by: RustFS <hello@rustfs.com> |
||
|
|
307fb13d32 |
chore(deps): upgrade object, dav-server, and zstd (#9364)
Pin object to 0.41.0 and upgrade dav-server to 0.12.0. Align the zstd adapter with the 0.14.4 registry implementation and update its dependency graph assertion and documentation. Implement the required WebDAV symlink metadata methods and cover regular entries and backend authorization with regression tests. Run two complete cargo update and cargo upgrade rounds after resolving the initial zstd version conflict. Co-authored-by: heihutu <heihutu@gmail.com> Co-authored-by: zhi22915 <qiuzgang@gmail.com> |
||
|
|
0f904a170e |
fix(clippy): satisfy lints introduced in Rust 1.100 (#9377)
* fix(clippy): satisfy lints introduced in Rust 1.100 * fix(clippy): cover Linux-only and feature-gated Rust 1.100 lints Restore the StorageError clone grouping check in the migration test, assert collection lengths before the rewritten test loops, and fix the needless_bool in the Linux-only heal readiness test and the redundant_clone in the swift formpost path. |
||
|
|
153d6b880d |
build(deps): re-pin rustfs/gateway to 7915d069 (#9283)
* feat(server): add the RUSTFS_S3_STACK selector and dual-stack e2e lane (#8411) * refactor(server): group the s3s-compat tower layers under legacy_compat (#8410) Move the ten tower layers that patch s3s behaviour out of rustfs/src/server/layer.rs into rustfs/src/server/legacy_compat/, one file per layer with its tests. Each file header names the s3s behaviour it patches, the gateway mechanism that replaces it (Replaced by:), and the task that removes it (Removed by: T2.12, rustfs/backlog#2771). The layers keep their code, their order in external_service_stack!, and their behaviour; no layer is deleted. Add server::http::tests::stack_census, which renders the ordered service chain of the real external_service_stack! expansion and compares it with a committed constant, so a reorder, insertion or removal is a visible diff. Route the two s3s error types the moved layers use through a storage_api::server::legacy_compat shim so the split adds no s3s-importing file, and lower the s3s footprint baselines to the measured values (files 209 to 208, s3_error! lines 1586 to 1585). Keep the server runtime-source bypass guard covering the moved code. Refs rustfs/backlog#2787, rustfs/backlog#2734 * feat(s3-types): add the RustFS-owned S3 error type and s3_error! macro (#8406) `rustfs-s3-types` now provides `S3ErrorCode` (generated by build.rs from src/codes.txt, the grep-derived call surface, plus `Custom`), `S3Error`, `S3Result`, `StdError` and the `s3_error` macro with the same call syntax as s3s, so the T1.2 codemod is a `use` swap. Statuses are hand-written and pinned to the s3s behaviour RustFS ships today by an oracle test that uses s3s as a dev-dependency only. The `From` conversions for the legacy edge live behind the off-by-default `compat-s3s` feature (the orphan rule forbids them in rustfs/src/error.rs); `rustfs` enables it. Refs rustfs/backlog#2742, rustfs/backlog#2734 * ci: add the per-crate test-count ratchet (#8404) Quick Checks now fails any PR that lowers the number of test attributes in a workspace crate or adds #[ignore], measured per crate against the exact rows of .config/test-count-baseline.txt (rustfs/backlog#2734 section 1 rule 3). The counter widens the spec's literal #[(tokio::)?test] to the tokio attributes that carry arguments and both spellings of #[test_case(...)], and anchors at line start so commented-out attributes do not count. The initial baseline covers 52 crates, 21077 tests and 164 ignored. Refs rustfs/backlog#2738 Refs rustfs/backlog#2734 * test(ecstore): pin the persisted bucket-config XML bytes for 13 families (#8408) Before any DTO or codec is replaced, pin the exact bytes that deserialize followed by serialize produces for every persisted bucket-configuration XML family in its three source shapes (AWS documentation, MinIO-written, RustFS-written), and the bytes RustFS writes today for a typed value. Byte equality only: a structural comparison would let a codec replacement change the persisted encoding unnoticed. The generator script refuses to overwrite existing goldens without --force, refuses on dirty codec paths, cannot report success from its write mode, and records the generating commit in the fixtures README. Refs rustfs/backlog#2744, rustfs/backlog#2734 * ci: raise the test-count baseline to the integration tree (#8426) * ci: make the s3s footprint baseline exact and lower-only (#8403) * ci: make the s3s footprint baseline exact and lower-only The s3s footprint guard compared three counters against ceilings held in the script itself, so a ceiling could sit above the tree and a drift was fixable by raising it (rustfs/rustfs#5964 raised the s3_error! ceiling to go green). The three values now live in .config/s3s-footprint-baseline.txt as files, s3_error_lines and ecstore_files, the script reads only that file, and a measurement that differs from its baseline in either direction fails: growth prints "s3s footprint grew: <measured> > <baseline>", shrinkage prints "lower the baseline to <measured> in this PR". The counting method is unchanged; the baseline is the current measurement of gateway/integration (209 / 1585 / 36). The header records the end state: once all three reach 0, T4.2 switches the script to failing on any occurrence. Refs rustfs/backlog#2739, rustfs/backlog#2734 * ci: add the s3s edge allowlist mode to the footprint guard (#8405) `scripts/check_s3s_footprint.sh --mode allowlist` fails on every Rust file that references s3s (`s3s::` or `s3s_sigv4`) and is not matched by an entry of the new `.config/s3s-edge-allowlist.txt`; `--dry-run` lists those files and exits 0. The allowlist carries the initial edge from the spec, and the script rejects an entry that names or matches anything under crates/ other than crates/e2e_test. The baseline mode and the argument-less CI invocation are unchanged. Refs rustfs/backlog#2741, rustfs/backlog#2734 * test(ecstore): reach the bucket-config codec through the test facade (#8428) * refactor(s3-types): own the HTTP Body and drop s3s from three crates (#8431) Add rustfs_s3_types::Body, a BoxBody<Bytes, StdError> wrapper with empty() and From<Bytes | Vec<u8> | String | &'static str>, and the legacy From conversions to and from s3s::Body behind compat-s3s. The signer is now generic over the request body: it only reads and writes the request head, so it needs no body type and its callers keep theirs. s3-client sends its requests with the owned Body, madmin signs a bodiless head, and targets drops its two S3Request/S3Response header wrappers in favour of extract_params_header. rustfs-signer, rustfs-madmin and rustfs-targets no longer depend on s3s; the s3s footprint baseline drops from 209 to 202 files. Refs rustfs/backlog#2747, rustfs/backlog#2734 * refactor(ecstore): move S3ErrorCode to rustfs-s3-types by codemod (#8432) * test(ecstore): pin the InvalidRange responses of new_getobjectreader Both error branches of new_getobjectreader build an ErrorResponse with S3ErrorCode::InvalidRange, and no test observed either code. Pin the code, its wire name and the location fields of each branch before the code type moves to rustfs-s3-types (rustfs/backlog#2743), so a changed code on either branch fails a test. The ecstore test-count row rises by the two tests. * chore(scripts): add the s3s-to-rustfs-s3-types error codemod Task T1.2 of rustfs/backlog#2734 (rustfs/backlog#2743) moves S3Error, S3ErrorCode, S3Result and s3_error! from s3s to rustfs-s3-types by script, one crate closure per PR. The codemod rewrites use trees (splitting mixed s3s imports) and qualified code paths, never comments or literals, adds the rustfs-s3-types dependency, drops s3s only from a crate that no longer names it, refuses every file of the s3s edge allowlist, takes --hold for a file whose type is fixed outside the closure, and prints a per-crate census. A second run changes nothing. Its self-test runs under make script-tests. * refactor(ecstore): take S3ErrorCode from rustfs-s3-types Output of scripts/codemods/s3_error_to_s3_types.py over crates/ecstore, crates/lifecycle, crates/scanner and crates/replication (rustfs/backlog#2743 batches 1 and 2). The ErrorResponse code field, the two InvalidRange constructions in new_getobjectreader and an unused tier import now use rustfs_s3_types::S3ErrorCode; the variant names and wire names are unchanged. lifecycle, scanner and replication reference none of the four error names. warm_backend.rs and warm_backend_s3.rs are held: they compare against rustfs_s3_client::ErrorResponse.code, which stays the s3s type until s3-client moves. * ci(footprint): count only s3_error! lines still on s3s's macro s3_error_lines counted every line holding the text `s3_error!`, which also matches the RustFS-owned `rustfs_s3_types::s3_error!`. A codemod that moves call sites onto rustfs-s3-types therefore could not lower it (rustfs/backlog#2743, decision 3; rustfs/rustfs#8432, gotcha 2). The counter now applies a textual, per-file and per-line rule that errs on the side of counting (full rule in the script header): - occurrences spelled `rustfs_s3_types::s3_error!` never count; - a line holding `s3s::s3_error!` always counts; - any other `s3_error!` line counts unless its file is cleared, that is, it imports the macro from rustfs_s3_types by name on a line starting with the use item (or defines it with `macro_rules! s3_error`) and does not also bring s3s's macro in (`use s3s::s3_error`, a `use s3s::{..}` tree naming it or a crate-root `*`, `use s3s::*`, or `#[macro_use] extern crate s3s`); - fail closed: a file matching neither form (`use super::*`, a crate-local re-export, a renamed or glob rustfs_s3_types import, a commented-out import, a comment-only mention) counts. Census of the 1585 lines on |
||
|
|
31e1e42ad7 |
refactor: land the s3s decoupling groundwork on main (#9276)
Lands gateway/integration on main: the guard rails and the domain decoupling for replacing s3s with rustfs/gateway (rustfs/backlog#2734, Phase 0 and Phase 1). The S3 edge is still s3s and no wire behaviour change is intended. - Guard rails: lower-only s3s footprint baseline and edge allow-list, per-crate test-count floor, 39 byte-level goldens for the persisted bucket-config XML families, a two-server differential harness over all 73 S3 operations, a JUnit differ, and a reference-parity lane against the sha256-pinned 1.0.5 binary. - Owned types: rustfs-s3-types (S3Error, S3ErrorCode, Body), RequestEnvelope, AuthzFacts. - Engine crates off s3s: ecstore, lifecycle, replication, scanner, protocols, s3select, s3-client, rpc. - Admin: error types moved; 300 of 314 Operation impls take the owned AdminRequest. - Server: the s3s-compat tower layers grouped under server/legacy_compat; RUSTFS_S3_STACK=legacy|gateway selector, where gateway refuses to start until the gateway edge exists. Fixes made on the branch that change ecstore and heal behaviour are listed in the pull request description. The per-commit history stays on gateway/integration. |
||
|
|
bf03b1117a | fix(swift): preserve bucket metadata with Swift tag values (#9218) | ||
|
|
1a7fb2461d | fix(webdav): join connection and reload tasks on shutdown (#9213) | ||
|
|
70a46d0e8c |
fix(webdav): support configured browser CORS access (#9205)
* fix(webdav): support configured browser CORS access Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> Signed-off-by: Hauser Zhi <housemecn@gmail.com> * perf(webdav): streamline CORS policy and preflight parsing Borrow connection-owned policy state and clone the backend only for actual requests. Validate borrowed header names and normalize HTTP lists when required. Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> Signed-off-by: Hauser Zhi <housemecn@gmail.com> --------- Signed-off-by: Hauser Zhi <housemecn@gmail.com> Co-authored-by: heihutu <heihutu@gmail.com> Co-authored-by: zhi22915 <qiuzgang@gmail.com> |
||
|
|
1556e05b8a |
fix(sftp): put directory objects as trailing-slash keys (#9180)
SFTP subdirectory mkdir and rmdir sent the on-disk __XLDIR__ marker through the public S3 API. After the suffix was reserved, those calls were rejected as invalid client keys, so ordinary directory operations failed while bucket mkdir still succeeded. Send the logical trailing-slash key and let storage encode the marker. Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Chris An <overtrue@users.noreply.github.com> |
||
|
|
7f5fa4b8f6 |
fix(protocols,kms,keystone): enforce client CA, protect the KMS probe (#9168)
Scan findings in the alternate-protocol front ends and the KMS and Keystone integrations: - WebDAV and FTPS read RUSTFS_WEBDAV_CA_FILE / RUSTFS_FTPS_CA_FILE, checked that the file existed, and then built their TLS listeners with with_no_client_auth(), so mTLS was never enforced. A shared protocols::common::tls::server_config builds the rustls config with a client-certificate verifier from the configured CA, startup fails on an invalid CA, and a CA cannot be combined with cleartext (backlog#3069). - The KMS readiness probe used a fixed key id that the key-lifecycle admin routes accepted like any customer key, so kms:DisableKey on it failed readiness on every node. The probe key is reserved from key management and a disabled probe key no longer counts as a backend failure (backlog#3115). - The Keystone middleware answered anonymous requests carrying a junk X-Auth-Token with the configured Keystone URL in the body while Keystone was unreachable; failures no longer disclose upstream locations, and the login cache is bypassed when a subscription token refresh is required (backlog#3116). |
||
|
|
41b13aeb8b |
fix(tls): unify FIPS provider policy across clients (#9125)
* fix(tls): enforce active FIPS provider at startup Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> * ci: provision FIPS validation runner Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> * fix(tls): validate FIPS before observability startup Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> * perf(tls): reuse the installed crypto provider Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> * fix(ecstore): gate Linux-only commit helpers Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> * refactor(tls): centralize FIPS provider policy Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> --------- Co-authored-by: heihutu <heihutu@gmail.com> Co-authored-by: zhi22915 <qiuzgang@gmail.com> Co-authored-by: Chris An <anzhengchao@gmail.com> |
||
|
|
c47c8f9f74 |
fix(sftp): allow bucket-scoped root listings (#8998)
* fix(sftp): allow bucket-scoped root listings Listing the SFTP root required s3:ListAllMyBuckets. Without it a bucket-scoped user got PermissionDenied on `ls /`; with it they saw every bucket on the instance. S3 ListBuckets and the WebDAV root (#6298) already fall back to a per-bucket filtered listing. When the global ListAllMyBuckets check is denied, list buckets through the session-aware ListBuckets path instead, so IAM filters the result to buckets the principal may ListBucket or GetBucketLocation. Principals with ListAllMyBuckets keep the unfiltered listing, and IAM outages and timeouts still fail as before. list_buckets_for_session and its request builder were WebDAV-only; they are now also compiled with the sftp feature. * fix(protocols): re-check the session key for bucket-scoped listings list_buckets_for_session built its request from the identity captured at login. Through the SFTP root-listing fallback, a service account disabled or expired after login could keep listing bucket names, unfiltered when its parent may list every bucket. Validate the session key with check_key_valid_with_context, as authorize_protocol_request does for every other protocol operation, build the request from the fresh credentials and is_owner, map an invalid key to AccessDenied, and attach the server context. The SFTP fallback now passes the session's request headers and transport security, like every other SFTP authorization. DummyBackend fails closed when no session listing is queued, matching the trait default, and gains a stall_authorization hook. New tests cover a service account disabled mid-session, IAM outage and timeout on the global check (no fallback), non-AccessDenied backend errors, truncation of fallback output and the fail-closed default. * test(protocols): compare error code without referencing s3s The session-listing test compared against s3s::S3ErrorCode, which made policy_test.rs a new s3s-referencing file and tripped the s3s footprint ratchet (210 files against a baseline of 209). Compare the code's string form instead. * fix(protocols): refresh session bucket discovery without stale copies Build bucket listing requests directly from freshly validated credentials and server-scoped ownership instead of cloning and replacing login state. Reuse the same authorization path for WebDAV capacity discovery. Preserve typed access-denied checks through the protocol facade, and cover request conditions, session-policy updates, revocation, listing bounds, and fallback deadlines with regression tests. Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> --------- Co-authored-by: Hauser <housemecn@gmail.com> Co-authored-by: heihutu <heihutu@gmail.com> Co-authored-by: zhi22915 <qiuzgang@gmail.com> |
||
|
|
d4d416ed47 |
fix(deps): upgrade russh and replace vulnerable zstd codecs (#8969)
* chore(deps): upgrade russh to 0.65.0 and refresh crates Run two cargo update and cargo upgrade rounds from origin/main. Adapt SFTP public-key callbacks to PublicKeyOffer and VerifiedPublicKey, preserving explicit rejection and password-only authentication. Cover the rejection policy with a pinned-host-key SSH handshake test. Refresh Arrow, Parquet, Brotli, ZIP, and compatible dependencies. Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> * fix(deps): route legacy zstd consumers to fixed codecs Replace the old registry implementation with a private version-constraint adapter backed only by zstd 0.14.3 and zstd-safe 8.2.0. Preserve legacy features and Avro, Arrow IPC, Parquet, and Kafka formats. Cover abandoned contexts, legacy decode errors, seekable bounds, stored frames, consumer interoperability, and resolved implementation versions. Record the adapter removal condition in the compatibility register. Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> --------- Co-authored-by: heihutu <heihutu@gmail.com> Co-authored-by: zhi22915 <qiuzgang@gmail.com> |
||
|
|
68ad1a1d7b | fix(protocols): enforce S3 policies for file protocol operations (#8262) | ||
|
|
f5956999a7 |
feat(webdav): report quota properties on PROPFIND (#8197)
dav-server queries get_quota once per PROPFIND without a path, so the driver now reports a single session-scoped (used, total) pair: - when every bucket visible to the session has a hard quota: the summed cached bucket usage against the summed quota limits (a bucket whose usage cache has no scanner snapshot yet counts as zero); - otherwise: the cluster's usable capacity, the same erasure-aware used/total the console dashboard shows, cached for 30s since WebDAV clients poll quota and storage-info fans out to every disk; - when neither source is available the properties are omitted from the response, which is the previous behavior. All inputs are cache or snapshot reads; reporting never triggers a scanner cycle or a live listing. Backend failures surface as FsError::GeneralFailure instead of a bogus zero capacity. Adds a session_capacity_view hook to the protocols StorageBackend trait (default: no capacity support, keeping quota properties omitted), its rustfs-side implementation, aggregation unit tests, and an e2e test covering both reporting modes. |
||
|
|
1f04a12abf |
fix(ftps): bound upload memory with multipart streaming (#8064)
* fix(ftps): bound upload memory with multipart streaming * fix(ftps): keep multipart upload within driver module |
||
|
|
5498b3e5d5 |
chore(deps): refresh RustFS tokio tar dependency (#7907)
* chore(deps): refresh RustFS tokio tar dependency Switch the astral-tokio-tar workspace alias to the released rustfs-tokio-tar 0.7.1 crate and remove the obsolete cargo-deny git source allowance. Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> * chore(deps): align AWS smithy dependency family Upgrade the AWS SDK and smithy crates together while patching aws-smithy-json 0.63.0 for the aws-smithy-types 1.7.0 DocumentObject API used by aws-config 1.12.0. Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> * revert(deps): use official AWS smithy compatible set Remove the local aws-smithy-json patch and roll the AWS smithy family back to the latest official combination that compiles with aws-config 1.12.0. Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> * docs(architecture): retire tokio tar cleanup entry Remove the stale cleanup-register entry after switching back to the released rustfs-tokio-tar crate, leaving no unmatched compatibility marker for the architecture guard. Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> * ci: restore table workflow failure contract Align the table functional workflow with the quick-check guard by letting suite failures stay red, generating PASS reports only from complete successful evidence, and preserving the shared backlog issue fallback for harness failures. Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> * fix(deps): expose rustfs tokio tar dependency name Use the published rustfs-tokio-tar dependency key throughout the workspace while keeping source imports on the crate's tokio_tar lib target name. Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> --------- Co-authored-by: zhi22915 <qiuzgang@gmail.com> |
||
|
|
f37e07cca3 |
fix(ecstore): refuse RMW and reads of unreadable bucket configs (#7759)
An XML bucket sub-config whose stored bytes cannot be parsed was still folded into "absent" on two paths: update_config_with handed it to mutate, which rebuilt it from nothing and overwrote the only copy of the bytes, and the tagging/lifecycle/CORS/website/logging/accelerate/request-payment getters reported ConfigNotFound. Add an explicit ConfigState (Absent / Valid / Unreadable) over the existing retained parse failure, refuse the read-modify-write of an unreadable target config before mutate runs (per config, other configs stay writable), and make those getters fail closed. GetBucketLifecycle now only maps ConfigNotFound to NoSuchLifecycleConfiguration. The Swift tagging rewrite recognizes the refusal by type instead of a string sentinel. Refs rustfs/backlog#1734 |
||
|
|
2231633ae1 | fix: preserve protocol service account claims (#7062) | ||
|
|
ceeff52229 | docs(swift): align README feature lists with router and handler wiring (#7033) | ||
|
|
ba7785d61d | chore(deps): migrate direct encoding deps to simd (#6690) | ||
|
|
d269b90201 |
fix(ci): restore main branch checks (#6465)
* fix(protocols): add missing test dependency * style(ecstore): fix decommission formatting |
||
|
|
201c653dcd | fix(ci): restore workspace lint compatibility (#6460) | ||
|
|
205337151a |
fix(webdav): allow bucket-scoped root listings (#6298)
* fix(webdav): allow bucket-scoped root listings * test(webdav): use public protocol export * test(webdav): initialize identity inline --------- Co-authored-by: cxymds <cxymds@gmail.com> |
||
|
|
3bde70d5b4 |
chore(protocols): narrow the SessionDiag blanket to its one unread field (#6266)
The last item-level bare allow of backlog#1823 step 10. `SessionDiag` itself is live — `sftp/server.rs` constructs one per accepted connection and `wedge_watchdog` reads `session_id`, `peer` and `last_activity_ms` off it — so the struct-level blanket was covering exactly one field: `accepted_at`, which is written at accept time and never read back. The allow moves onto that field with a reason. The three remaining `#![allow(dead_code)]` in this crate (`sftp/test_support.rs`, `common/dummy_storage.rs`) are module-root blankets in test-support files, which belong to steps 1-5 rather than step 10. Refs backlog#1823 |
||
|
|
3ff250f1cd |
chore(protocols): drop 43 no-op dead_code allows from swift (#6157)
backlog#1823 step 8, partial. The swift module carries 43 #[allow(dead_code)] attributes, most with a comment naming a consumer: "Used by handler", "Handler integration: GET container", "Used by handler and object.rs". Every one of them suppresses nothing. crates/protocols/src/lib.rs declares `pub mod swift`, and swift/mod.rs declares all 22 submodules `pub mod`, so every item is publicly reachable and dead_code never applied to it. Removing all 43 leaves the warning count at zero, in both the default and --features swift lanes. That is also why those comments survived. They assert who calls the item — a claim the compiler normally settles on its own — and the compiler had been silenced by the visibility chain. The rest of step 8 needs a decision this PR does not make. Downgrading the 22 submodules to `pub(crate) mod` does restore detection, and it surfaces 39 real items, 16 of them the whole of sync.rs: SyncConfig, SyncStatus, SyncQueueEntry, ConflictResolution and every function and constant around them, i.e. Swift container sync is built and never wired. But the `pub mod` chain is load-bearing. Six integration tests under crates/protocols/tests are separate crates that import the submodules directly (swift::quota, swift::slo, swift::symlink, swift::sync, swift::tempurl, swift::container), and the downgrade fails to compile them. Restoring dead-code detection for this module therefore depends on first deciding whether those tests move in-crate — which is a testing-strategy call, not a cleanup one. Verification: cargo check -p rustfs-protocols warning-free in the default lane and with --features swift (lib and --tests); clippy --features swift --lib --tests -D warnings clean; cargo nextest run -p rustfs-protocols --features swift 441 passed; make pre-commit exit 0. Ref rustfs/backlog#1823 (step 8). |
||
|
|
d60a77b750 |
fix(quota): enforce durable hard quota reservations (#6058)
* fix(quota): enforce durable hard quota reservations * fix(quota): close reservation bypasses * fix(quota): isolate tests and box object futures * fix(quota): close legacy and deferred settlement bypasses * fix(app): keep object futures off caller stacks * fix(metrics): preserve object operation labels * fix(logging): retain GET trace guard contract |
||
|
|
aa4d3317ed |
perf(ecstore): guard inline data-read metadata early-stop (#6069)
Add a default-off inline-only data-read metadata early-stop gate that verifies inline plaintext before cancelling pending metadata tasks. Keep non-inline, prepared, and request-shape-sensitive reads on full fanout, and record scheduled/completed/cancelled ReadVersion lifecycle metrics for normal fanout completion. Co-authored-by: heihutu <heihutu@gmail.com> |
||
|
|
134081b27b |
chore(deps): fix cargo shear dependency metadata (#5854)
Co-authored-by: heihutu <heihutu@gmail.com> |
||
|
|
78d6918c52 |
feat: extend hotpath coverage across crates (#5505)
Add opt-in hotpath feature surfaces to every workspace crate and wire the root rustfs feature passthrough for function, allocation, and CPU profiling. Add a focused set of function-level measurements for scanner, heal, lock, target replay, IAM, KMS, Keystone, trusted proxy, and capacity paths without adding request-scoped primitive wrappers. Co-authored-by: heihutu <heihutu@gmail.com> |
||
|
|
2dea4a9acf |
fix(s3): correlate server-owned request IDs (#5433)
* fix(s3): correlate server-owned request IDs * fix(server): preserve trace context and Swift routing --------- Co-authored-by: houseme <housemecn@gmail.com> |
||
|
|
c9397405ed | ci(protocols): inherit workspace lint policy (#5436) | ||
|
|
f7c1b13c0f |
refactor(deps): replace md5 crate with md-5 (#5432)
Co-authored-by: heihutu <heihutu@gmail.com> |
||
|
|
3fe74a5019 | fix(swift): merge account and container metadata POSTs (#5414) | ||
|
|
957080bea5 |
fix(swift): persist container and account metadata writes (#5398)
Swift container and account metadata handlers cloned the cached BucketMetadata, set the tagging fields, and called set_bucket_metadata, which only updates the in-memory cache map. Nothing reached .metadata.bin, so every Swift metadata POST was lost on restart and silently overwritten by the next disk-truth reload (a peer LoadBucketMetadata notification or the 15-minute refresh loop) — while the client had already been told 2xx. Route these writes through a new metadata_sys::update_config_with: a read-modify-write that loads the on-disk metadata and persists the result under the same write guard metadata_sys::update uses, so the rewrite merges against disk truth instead of a possibly stale cache and cannot clobber a concurrent update to another config file. Peers are notified afterwards, matching the S3 config handlers. Persisting these writes required hardening the paths that now produce durable state: - Account metadata writes validate account ownership. This metadata holds the account's TempURL signing key, so an unauthenticated write for someone else's account would have become a durable, cluster-wide takeover of that account's pre-signed URLs. Reads stay open because TempURL signature validation runs before credentials exist. - disable_versioning verifies the container exists. Without it the metadata loader's "no metadata on disk" default would be persisted, creating an orphan metadata file and caching a fabricated default as authoritative. - Container and account metadata are size- and count-limited, reusing the Swift limits object metadata already enforces; these tags land in the bucket metadata file that every later config write rewrites whole. - A rewrite refuses to run when the persisted tagging config is unreadable, instead of merging onto an empty set and wiping the container ACL and versioning tags. It reports 409 naming the remedy. - Storage errors are logged in full and reported generically, since they now carry real disk and quorum detail. The tagging arm of BucketMetadata::update_config also clears the parsed config, as the lifecycle arm does: parse_all_configs skips empty XML rather than clearing, so a cleared config kept serving the old tags. Tagging is serialized with the S3 XML serializer the loader can parse back, not quick_xml, whose output was never round-trippable. |
||
|
|
e822fc1552 | fix(swift): enforce cumulative container quotas (#5378) | ||
|
|
2f6115e058 | fix(swift): enforce TempURL IP restrictions (#5377) | ||
|
|
b2a376c2d2 |
Merge commit from fork
* fix(admin): bound IAM import archive expansion MAX_IAM_IMPORT_SIZE caps the compressed upload at 10 MB, but every member of the archive was then read with read_to_end into an unbounded Vec. Deflate ratios well above 100:1 are easy to construct, so a small authorized upload could expand without limit across the seven members ImportIam reads. Add a shared expansion budget (MAX_IAM_IMPORT_EXPANDED_SIZE, 10x the compressed cap) drawn down by every member, and route all seven reads through one helper that reads a byte past the remaining budget to detect overrun. Sharing the budget bounds the archive as a whole rather than letting each member spend the full limit independently. Covers R03-CAN-024 through R03-CAN-030 plus R04-CAN-077 (backlog #1471) — one fix rather than seven, since all seven call sites were byte-identical. * fix(kms): confine local key paths and refuse silent key replacement Local KMS key identifiers arrive from request input — the `name` tag on CreateKey, the `keyId` body field or query parameter on DeleteKey — and were joined onto `key_dir` with no validation. An identifier such as `../../tmp/evil` escaped the configured directory, making key creation a constrained arbitrary-file write and `DeleteKey` with `force_immediate` a cross-directory delete. Validate in `master_key_path` and make it fallible, so every filesystem path in this backend inherits the guard: decode_stored_key, load_master_key, save_master_key, create_key and delete_key all derive their paths there. The rule is containment rather than a character allowlist, so identifiers already in use keep resolving; only separators, NUL, absolute paths and non-single-component forms are refused. Note `.` and `..` are contained rather than refused — the `.key` suffix turns them into the ordinary filenames `..key` and `...key`. Separately, `LocalKmsBackend::create_key` had no existence check, while the sibling `KmsClient::create_key` has always had one. Since `save_master_key` renames over its destination, creating a key under an existing name silently replaced its material and destroyed the ability to decrypt everything wrapped under it — and the backend path is the one the admin API uses. It now returns KeyAlreadyExists, matching StaticKmsBackend. Covers R03-CAN-072, R03-CAN-073 and R07-CAN-103 (backlog #1475). R03-CAN-073 needed no separate change: delete_key routes both its load and its remove_file through master_key_path. * fix(swift): bound SLO manifest reads to the 2 MiB manifest limit The three Swift SLO handlers that load a stored manifest (handle_slo_get, handle_slo_get_manifest, handle_slo_delete) read the `<object>.slo-manifest` object to EOF with AsyncReadExt::read_to_end. That key is predictable and writable through the ordinary object PUT path, so a tenant can replace the manifest with an arbitrarily large object and then make the server allocate its full size on every SLO GET, multipart-manifest=get, or multipart-manifest=delete request - a memory amplification bounded only by the stored object size (CWE-400 / CWE-770). The 2 MiB manifest limit that handle_slo_put enforces was not applied on the read side. Introduce MAX_SLO_MANIFEST_SIZE (the existing 2 MiB PUT limit, now a named constant) and a shared read_manifest_bytes helper that reads through a `take(limit + 1)` and rejects anything larger, so an oversized manifest is refused instead of being buffered first. All three call sites go through the helper. handle_slo_put now checks the size before parsing the JSON. Regression tests: test_read_manifest_bytes_rejects_oversized_manifest and test_read_manifest_bytes_stops_reading_oversized_manifest (which asserts the reader is not consumed past the limit), plus a boundary test that a manifest at exactly 2 MiB is still accepted. * fix(protocols): authorize every object in FTPS/WebDAV recursive deletes The FTPS and WebDAV gateways authorized only the container before a recursive delete and then destroyed everything inside it without a further check: - FTPS RMD (and DELE on a bucket path ending in '/') cleared s3:DeleteBucket, then delete_bucket_recursively listed the bucket and deleted every object. - WebDAV DELETE on a bucket did the same via its own delete_bucket_recursively. - WebDAV DELETE on a directory cleared s3:DeleteObject for the directory marker key ("dir/") only, then listed that prefix and deleted every child under it. A principal holding s3:DeleteBucket (or s3:DeleteObject on a single marker key) could therefore erase objects it had no s3:DeleteObject permission for, and the operation reported success. Deletion stays recursive - that is the expected behaviour for these protocols - but each object now clears s3:DeleteObject on its own key before it is removed, and the enumeration clears s3:ListBucket. A denial aborts the whole operation with access denied rather than being skipped, so the caller can never be told the delete succeeded while objects were left behind or removed without authorization. The test double gained shared-state cloning, delete_object/delete_bucket call logs, and list/delete queue helpers so the regression tests can observe that nothing is deleted once a deny lands. * fix(server,ecstore): bound TLS handshakes and remote volume RPC waits Three call sites let an unauthenticated client or a misbehaving peer hold server resources with no deadline. TLS listener (R03-CAN-035): process_connection awaited `acceptor.accept(socket)` with no bound. A client that opens a TCP connection and never finishes the handshake parks a Tokio task and a socket forever, and the connection cap (RUSTFS_API_MAX_CONNECTIONS) is unlimited by default, so nothing else sheds it. The handshake now runs under accept_tls_with_deadline(), reusing the existing HTTP/1 header-read budget — the established slow-client bound for the pre-request phase — and the expiry is recorded through the same log/metric path as a handshake error, under a new TIMEOUT failure kind. Remote disk RPCs (R03-CAN-049, R03-CAN-050): list_volumes and delete_volume passed Duration::ZERO, which execute_with_timeout treats as "no deadline", so a peer that accepts the request and never answers stalls the coordinator (and, for delete_volume, the bucket-deletion workflow). Both now pass get_max_timeout_duration(), matching every sibling method in the file. Regression tests: a silent TLS peer must be shed by the handshake deadline; list_volumes/delete_volume against a peer that completes the TCP connect and then goes silent must fail with DiskError::Timeout instead of hanging. * fix(security): stop leaking signed headers and bound OIDC/KMS credentials Three independent hygiene fixes found by the security review. R03-CAN-018 (crates/signer): try_get_canonical_headers and get_signed_headers logged the complete header map at DEBUG before signing. Runtime callers pass session credentials and SSE-C key material through these headers, so anyone able to raise the log level (or read DEBUG logs) recovered X-Amz-Security-Token and SSE-C keys verbatim. The statements were debugging leftovers with no operational value and are deleted rather than redacted. R03-CAN-014 (crates/iam): the OIDC HTTP adapter buffered provider responses with an unbounded Response::bytes(), so a configured, compromised or attacker-pointed IdP endpoint could stream an arbitrarily large or endless body into memory (the ValidateOidcConfig admin handler lets a ServerInfo caller choose the endpoint). Responses are now read incrementally and fail closed past MAX_OIDC_RESPONSE_SIZE, and the already SSRF-hardened client builder gains request and connect timeouts so a stalled provider cannot pin the calling task indefinitely. R07-CAN-105 (helm): the Vault KMS token was serialized into the chart ConfigMap, exposing it to every subject allowed to get ConfigMaps in the namespace. It now renders into a dedicated Secret that the Deployment and StatefulSet consume via envFrom; the Secret is separate from the main credentials Secret so it also works when secret.existingSecret is set. Regression tests: - rustfs-signer: signing_never_logs_signed_header_material - rustfs-iam: oidc_response_body_past_the_limit_is_rejected, oidc_response_body_at_the_limit_is_accepted - scripts/test_helm_templates.sh: KMS token must never render in plaintext * fix(webdav): enforce body limit, request timeout and connection cap The configured WebDAV maximum body size was enforced from Content-Length, so a chunked request declared no length and bypassed it entirely. The configured request timeout was never applied to the connection at all, and the accept loop spawned a task per connection with no bound, so an unauthenticated client could hold resources indefinitely and in unbounded number. Enforce the limit on bytes actually read rather than the declared length, apply the configured timeout to the request, and bound accepted connections with a new RUSTFS_WEBDAV_MAX_CONNECTIONS (default 1024) surfaced in the config report. Covers R03-CAN-051, R03-CAN-052, R03-CAN-067, R04-CAN-089, R05-CAN-094 and R05-CAN-097 (backlog #1471, #1474). * fix(security): stop STS credentials from crossing the parent trust boundary Two related credential-boundary holes let a short-lived STS credential act with the full, unrestricted authority of the long-term user it was minted from. AddUser (R03-CAN-021, CWE-269/863): should_check_deny_only relaxes the admin policy check to deny-only when a Console/STS session targets the IAM user it represents. Nothing then stopped that session from calling AddUser with its own parent's access key, so the handler wrote an attacker-chosen secret key and status over the parent's stored Credentials via create_user -> save_user_identity. A session that expires in minutes became permanent control of the account. AddUser now rejects any temp or service-account requester whose resolved parent equals the target access key, resolving the parent the same way should_check_deny_only does (parent_user field, else the JWT `parent` claim, since some stores persist the parent only in the token). FTPS/SFTP/WebDAV password auth (R04-CAN-086, CWE-287/862): these protocols looked the access key up with check_key, which falls back to the STS account cache, and then compared only the stored secret. An STS access key plus secret therefore authenticated with no session token presented and no session-policy claims applied - the holder got the parent's full permissions. Password authentication now rejects temporary credentials before the secret comparison. The discriminator is is_temp() && !is_service_account(), the same one IamCache::update_user_with_claims uses to route an identity into the STS cache, so service accounts - which resolve policy from stored IAM state rather than a client-presented token - keep working over these protocols. Regression tests cover both predicates and pin the guards to their call sites so neither can be dropped without a test failure. |
||
|
|
7f19e9a465 |
Merge commit from fork
docs/testing/security-regressions.md requires every fixed advisory to map to a named, greppable regression test. Rename the tests added with the fixes to carry their advisory id so `rg -i ghsa` finds them, and add the four rows to the advisory -> test map. Adds the FTPS MKD regression test that was missing. It primes the dummy backend with a successful create_bucket, so the assertion distinguishes "denied at the authorization boundary" from "backend refused" — without the queued success an unconfigured create_bucket fails on its own and the test would pass even with the authorization check removed. Verified it fails when the check is reverted. DummyBackend gains a Debug impl (FtpsDriver's trait bounds require it) and a queue_create_bucket_ok helper. Records in the CI-execution map why ghsa_g3vq_* runs in the default pass despite sitting behind the ftps feature: the rustfs crate defaults to ["ftps", "webdav"] and cargo unifies features across the workspace build, so the test executes there even though `cargo test -p rustfs-protocols` alone would skip it. |
||
|
|
92f83bfe15 |
Merge commit from fork
* fix(policy): quantify negated string conditions per value
ForAllValues:/ForAnyValue: negated string operators computed the positive
quantified match and then negated the aggregate. That yields NOT(all match)
and NOT(any match), which is the semantics of the *other* quantifier, so
ForAllValues:StringNotEquals and ForAnyValue:StringNotEquals were exactly
transposed. The same applied to StringNotEqualsIgnoreCase, StringNotLike,
ArnNotEquals and ArnNotLike.
Introduce an explicit Quantifier and push negation into the per-value
predicate for the qualified forms, so ForAllValues requires every request
value to satisfy the operator and ForAnyValue requires at least one.
Unqualified operators keep negating the aggregate, preserving AWS
single-valued-key semantics. Absent keys now follow AWS: ForAllValues is
vacuously satisfied, ForAnyValue is not.
A request value set that is fully contained in or fully disjoint from the
policy set cannot distinguish the two quantifiers, which is why the existing
cases missed this; the new tests use partially overlapping sets.
* fix(auth): keep request headers out of server-derived condition keys
get_condition_values folded every remaining request header into the policy
condition map. HeaderMap lowercases header names, and the server-derived keys
userid, username, principaltype, versionid and signatureversion are lowercase
too, so a header of the same name collided with them. The collision branch used
extend(), and non-quantified string operators match if ANY value in the vector
matches, so sending `userid: admin` was enough to satisfy a condition on
aws:userid. The jwt:/ldap: claim keys were reachable the same way whenever the
credential carried no such claim.
groups was worse than an append: the header loop ran before the cred.groups
block, which is gated on !args.contains_key("groups"), so a `groups:` header
both injected a value and suppressed the credential's real group list.
Resolve claims and group membership before merging headers, then skip any header
naming a key the server already derived or a well-known identity/context key.
The reserved set comes from KeyName so it tracks the key registry; s3:x-amz-*
keys stay mergeable because they mirror request headers by design.
* fix(access): gate the ListBucketVersions fallback on public-access checks
An anonymous request for ListObjectVersions that the bucket policy does not
grant directly falls back to re-checking the grant as s3:ListBucket. That
fallback returned Ok(()) straight away, skipping the two gates the direct grant
passes through: deny_anonymous_table_data_plane_if_needed and the
RestrictPublicBuckets check on the bucket's public-access block.
So a bucket whose policy allows anonymous s3:ListBucket kept serving anonymous
version listings after an operator enabled RestrictPublicBuckets, even though
the equivalent GetObject was correctly denied.
Fold the fallback into policy_allowed so both routes reach the same gates.
* fix(ftps): authorize MKD against the CreateBucket boundary
FTPS MKD creates a bucket but ran no authorization check, so any principal that
could open an FTPS session could create buckets regardless of policy. Every
other operation in this driver authorizes first — LIST, RETR, STOR, DELE and
RMD all call authorize_operation — and the WebDAV gateway checks
S3Action::CreateBucket on the equivalent path.
Add the matching check so MKD clears the same boundary as an S3 CreateBucket.
|
||
|
|
c82ee6be58 |
feat(api): wire opt-in per-client S3 API rate limiting (429 + Retry-After) (#4895)
feat(api): wire opt-in per-client S3 API rate limiting (backlog#1191) RustFS shipped three rate-limiter implementations and none was wired to any request path: the tower layer never returned 429 (its over-limit branch passed requests through) and was never instantiated, the console env switches only logged, and the Swift token bucket was never called. Replace them with one working, default-off implementation: - Rewrite rustfs/src/server/rate_limit.rs as a sharded per-client-IP token-bucket limiter (32 mutex shards instead of one global RwLock write per request), bounded at 100k tracked IPs with lossless refilled-idle sweeps, returning 429 + Retry-After + x-ratelimit-* headers and an S3-style XML body. - Key on trusted-proxy-validated ClientInfo.real_ip, else the socket peer address; never read spoofable X-Forwarded-For/X-Real-IP headers. Requests without a resolvable identity fail open. The echoed request id is charset-gated to prevent reflected XML injection. - Wire the layer once at startup via option_layer between CatchPanicLayer and ReadinessGateLayer (external stack only), gated by new RUSTFS_API_RATE_LIMIT_ENABLE/_RPM/_BURST constants; health and profiling probes, internode RPC/gRPC, and the console are exempt. - Make RUSTFS_CONSOLE_RATE_LIMIT_ENABLE/_RPM actually enforce by reusing the same limiter core through an axum middleware. - Delete the dead Swift ratelimit module, its isolated tests, and the stale logging-guardrail entry; keep the live SwiftError 429 mapping. - Add unit tests (exhaustion/recovery with injected time, concurrency, cap eviction, spoofed-header and fail-open behavior, env matrix) and e2e tests proving 429 + Retry-After on the real server and zero behavior change with default configuration. |
||
|
|
48b328d0d2 |
chore(deps): tighten crate dependency features (#4896)
* chore(deps): tighten crate dependency features Narrow Tokio and dependency feature declarations for protocols, TLS runtime, utils, targets, and replication based on direct crate usage. Co-Authored-By: heihutu <heihutu@gmail.com> * chore(deps): trim hyper-rustls features Keep direct hyper-rustls features aligned with the actual RustFS call sites. rustfs-targets only needs native root loading and the rustls provider/TLS policy features for MQTT TLS config construction, while rustfs-ecstore needs the HTTP connector protocol features but not webpki roots. Co-Authored-By: heihutu <heihutu@gmail.com> --------- Co-authored-by: heihutu <heihutu@gmail.com> |
||
|
|
56179210ab |
chore(deps): simplify dependency features (#4890)
* chore(deps): remove redundant dependency features Remove manifest feature entries that are implied by other requested features in the same dependency declaration. Verified that the resolved Cargo feature graph is unchanged after the cleanup. Co-Authored-By: heihutu <heihutu@gmail.com> * chore(deps): narrow tokio and reqwest features Co-Authored-By: heihutu <heihutu@gmail.com> --------- Co-authored-by: heihutu <heihutu@gmail.com> |
||
|
|
f3a7a4b0da |
chore(deps): localize workspace dependency features (#4888)
Move workspace-level dependency feature lists into the member crates that consume each dependency while keeping required default-features flags at the workspace root. Also refresh starshard to 2.2.2 via cargo update and cargo upgrade --exclude ratelimit. Co-authored-by: heihutu <heihutu@gmail.com> |
||
|
|
c41062f278 | fix(protocols): constant-time FormPost signature check and guard DLO/SLO range underflow (#4519) | ||
|
|
87357a0fdd | fix(swift): escape static-website listing to prevent stored/reflected XSS (#4515) |