Repository navigation
feat(api): read an authorized document and answer every refusal with the same 404 - #27
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
Milestone item 2.6. The existence invariant says that "you may not see this" and "this does not exist" look the same from outside. Search already returned no counts of filtered rows. There was no way to read a single document, though, and that is the endpoint where a careless 403 would give existence away.
Contract
Design decisions
AuthorizedChunkQueryand the compiled predicate. A document is readable exactly when its chunks are retrievable, and there is no second rule that could drift from search.denycarries no reason. The audit event records that the key was not visible to the principal and nothing else. The audit log therefore does not become a list of which hidden documents exist.How it is verified
allowordenywith empty attributes, and a malformed key leaves no event.Timing differences between these cases are not mitigated. The authorization document lists this as a residual risk, and the threat model will cover it.
背景
里程碑的 2.6 项。存在性不变量的要求是:从外部看,「你无权查看」和「它不存在」表现一致。检索此前已经不返回被过滤的数量。但系统还没有读取单篇文档的接口,而这正是一个随手返回 403 就会暴露存在性的地方。
契约
接口的行为见英文部分的代码块:已授权时返回
{key, title, versionNo};其他所有情况返回完全相同的 404。设计决定
读取流程见英文部分的伪代码。
AuthorizedChunkQuery和编译好的谓词。一篇文档可读,当且仅当它的 chunk 可以被检索到;不存在第二套可能和检索不一致的规则。deny不带原因。 审计事件只记录这个 key 对该身份不可见,不记录别的。这样审计日志不会变成一份「哪些隐藏文档存在」的清单。如何验证
allow或deny,属性为空;格式不合法的 key 不留下任何事件。这几种情况之间的耗时差异没有做处理。授权文档把它列为残余风险,威胁模型会覆盖这一点。