Repository navigation
Conversation
Ignore user attributes with the reserved `$Object:` prefix in both eACL header builders, including parent headers. Closes #4300. Signed-off-by: Andrey Butusov <andrey@nspcc.io>
Match raw and decoded GET headers without building complete header lists. Avoid protobuf round-trips for decoded headers and scan user attributes linearly. Cache all system values on the first system filter to avoid repeated header parsing. Preserve existing ACL behavior. ``` Benchmark ns/op B/op allocs/op BenchmarkMessageHeaderValues/attrs=10/distinct5/same/binary=false/lazy=false-16 8669.0 3407.0 34.0 BenchmarkMessageHeaderValues/attrs=10/distinct5/same/binary=false/lazy=true-16 1209.0 608.0 6.0 BenchmarkMessageHeaderValues/attrs=10/distinct5/same/binary=true/lazy=false-16 5061.0 1369.0 33.0 BenchmarkMessageHeaderValues/attrs=10/distinct5/same/binary=true/lazy=true-16 3431.0 896.0 5.0 BenchmarkMessageHeaderValues/attrs=10/mixed5/same/binary=true/lazy=false-16 6125.0 1369.0 33.0 BenchmarkMessageHeaderValues/attrs=10/mixed5/same/binary=true/lazy=true-16 7203.0 1425.0 15.0 BenchmarkMessageHeaderValues/attrs=100/distinct5/same/binary=false/lazy=false-16 28768.0 19088.0 124.0 BenchmarkMessageHeaderValues/attrs=100/distinct5/same/binary=false/lazy=true-16 1472.0 608.0 6.0 BenchmarkMessageHeaderValues/attrs=100/distinct5/same/binary=true/lazy=false-16 39650.0 9729.0 216.0 BenchmarkMessageHeaderValues/attrs=100/distinct5/same/binary=true/lazy=true-16 28009.0 4032.0 5.0 BenchmarkMessageHeaderValues/attrs=100/repeated20/same/binary=false/lazy=false-16 58922.0 19087.0 124.0 BenchmarkMessageHeaderValues/attrs=100/repeated20/same/binary=false/lazy=true-16 12581.0 608.0 6.0 BenchmarkMessageHeaderValues/attrs=100/repeated20/same/binary=true/lazy=false-16 67427.0 9729.0 216.0 BenchmarkMessageHeaderValues/attrs=100/repeated20/same/binary=true/lazy=true-16 43242.0 4032.0 5.0 BenchmarkMessageHeaderValues/attrs=100/mixed5/same/binary=true/lazy=false-16 44800.0 9729.0 216.0 BenchmarkMessageHeaderValues/attrs=100/mixed5/same/binary=true/lazy=true-16 35214.0 4564.0 15.0 ``` Ref nspcc-dev/neofs-sdk-go#913. Signed-off-by: Andrey Butusov <andrey@nspcc.io>
Check the parent header before sending any object data through the local and remote EC streaming paths. Reuse binary header validation and skip it when no recheck is armed. Add regression tests for filtered rules and reserved-key spoofing, including owner and payload-size whitelists. Reported-by: Fabian Wahle <fabian@nash.io> Signed-off-by: Andrey Butusov <andrey@nspcc.io>
|
/hal please review this with nspcc-dev/neofs-sdk-go#913 |
7ce3613 to
43cdba3
Compare
There was a problem hiding this comment.
This PR fits SDK nspcc-dev/neofs-sdk-go#913 (a60c2cfbeb1b): messageHeaderValues meets the HeaderValueSource contract, including the rule that an unavailable header type is reported only when the object header is incomplete. The new EC recheck still lets one kind of eACL Deny rule through, though. The EC fast paths pass the header as []byte, and that path never sees the request's X-headers. So a Deny rule that combines a request-header filter with an object filter does not match, and the object is streamed to the client.
What I checked
- The changes, read against the SDK diff in #913:
ValidationUnit.WithHeaderValueSource,matchHeaderValuesandmatchHeaderValue. I compared the node's value source with the legacyheaderSourcefor each message type: binary, decoded, storageHeadand address-only. go test ./pkg/services/object/ ./pkg/services/object/acl/...passes at 7b27345.go mod tidy -diffprints nothing. The otel/logr bumps ingo.sumcome in with the new SDK revision.TestServer_Get_ECEACLfails in every recheck case (local and remote) onceecTransport.checkHeaderis not set. The test does cover the fix.- I added one case to that test, in a scratch copy and not pushed: the request carries the X-header
role=guest, and the table hasDeny GET Otherswith two filters,NewRequestHeaderFilter("role", MatchStringEqual, "guest")andclassified == secret. It fails for bothremote=falseandremote=true: the client gets the header and the payload instead ofObjectAccessDenied(the inline comments below have the details).
Findings
- The binary recheck drops the request's X-headers (inline on
acl.goandvalues.go). This gap already existed on the non-EC buffer path. It is not a regression for EC, which had no recheck at all before this PR. But it means the restored EC recheck is weaker than theValidateHeaderpath it stands in for. Open PR #4305 (closes #4297) fixes the binary path by adding a request parameter toWithObjectHeaderBinary. Whichever of the two PRs merges second has to extend theHeaderFromRequestbranch invalues.goto read the request from the binary message too. Otherwise the lazy source keeps the gap even after #4305 lands. checkBinaryHeaderreturnsErrNotMatchedunchanged (inline). As far as I can tell this is not reachable today: a binary header never setsincompleteObjectHeaders. If it ever were reached, it would turn a basic-ACL fallback into an error status.
Smaller points (profile conventions)
pkg/services/object/acl/eacl/v2/object.go:47-85:dst.wantsSystemValues()cannot change whilecollectObjectHeadersruns, so a single check around the system-value block would replace the nine identical guards.collectBinaryObjectHeadersAtrepeats the pattern at its end.values_test.gobuilds the same protobuf header fixture (header slice, size,MarshalStable) about ten times, and builds the binary/decoded/response source table in several tests. The profile asks for one shared constructor.pkg/services/object/server.go:2223still spells"$Object:"as a literal, next to the newreservedAttributePrefix.- The first commit (
sn/object: prevent system eACL property spoofing) saysCloses #4300, but its CHANGELOG line cites #4338, which is the separate open PR carrying the same fix. Per the profile, the line should end with the issue number. Also worth deciding whether that commit lands through #4338 or through this PR. go.modpins an unmerged SDK PR commit. It will need re-pinning once #913 merges, and moving again if #913 changes in review.
Not determined: I did not build a live EC placement for the split-object range entry points (copySplitECObjectRangeByInfo/ByLinker/ByParts combined with payload-only), so I cannot confirm that none of them sends a header without the recheck. The other EC transports either reject an init part or write only payload.
Generated review by hal0x9000 for commit 7b27345.
| } else if b, ok := msg.([]byte); ok { | ||
| hdrSrcOpts = append(hdrSrcOpts, eaclV2.WithObjectHeaderBinary(b)) | ||
| } else if hdr, ok := msg.(*object.Object); ok { | ||
| req, _ := reqInfo.SrcRequest.(eaclV2.Request) |
There was a problem hiding this comment.
On this path the request is never handed to the header source. WithObjectHeaderBinary(b) (L172) carries only the bytes, unlike the *object.Object case on these lines. The EC fast paths this PR adds (getECTransport.checkHeader) and the existing buffer callback both reach CheckEACL with []byte. So every HeaderFromRequest filter sees no values during the deferred recheck.
How it fails: a client sends a GET with X-header role=guest, and the table has Deny GET Others with filters role == guest (request) and classified == secret (object). The initial check cannot read the object, so it defers. The binary recheck then finds no role value, the record does not match, and the EC object is streamed. I added this case to TestServer_Get_ECEACL in a scratch copy: it fails for both remote=false and remote=true (2 responses instead of the 1 ObjectAccessDenied).
Open PR #4305 fixes this for the binary path (WithObjectHeaderBinary(b, reqInfo.SrcRequest.(eaclV2.Request))). Either rebase onto it, or pass the request here the same way you do for *object.Object.
| req = m.req | ||
| case responseXHeaderSource: | ||
| req = m.req.req | ||
| case decodedHeader: |
There was a problem hiding this comment.
This switch takes the request from requestXHeaderSource, responseXHeaderSource and decodedHeader, but not from binaryHeader, so binary messages always get req == nil. Once the binary option carries the request (see the comment on acl.go, and #4305), this branch needs a matching case. Otherwise the lazy source keeps the gap while the legacy HeadersOfType gets fixed. Whichever PR merges second should add a test for a request-header filter with a []byte message.
| if err != nil && !errors.Is(err, aclsvc.ErrNotMatched) { | ||
| return eACLErr(s.reqInfo, err) | ||
| } | ||
| return err |
There was a problem hiding this comment.
ErrNotMatched goes back to the caller unchanged here, while ValidateHeader just above treats it as "follow basic ACL" and returns nil. With a binary header I could not make it happen: incompleteObjectHeaders is never set, so CalculateAction always gives a final answer. If it ever did happen, the EC path would abort and Get would send it through sendStatusGetResponse as a failure. Returning nil would match ValidateHeader:
| return err | |
| return nil |
| ) | ||
|
|
||
| // headerValueSet borrows user attributes and caches system values on first use. | ||
| // Linear scans avoid per-key indexes for small headers. |
There was a problem hiding this comment.
The profile asks that implementation rationale not go into code comments and that an explanation not appear twice. The caching rule is stated here and again in the NewMessageHeaderValueSource doc (L42-45), and "Linear scans avoid per-key indexes" is rationale that belongs in the commit message. Suggest one line saying what the type holds, and a one- or two-sentence doc on the constructor.
Ref nspcc-dev/neofs-sdk-go#913.