资源 · 58

红绿灯:验证文档访问权限和隔离

测试检索、引用、缓存和撤销功能,以确保文档助手尊重每个用户的权限。

已更新 · 14 min

无人实验室中的私有人工智能计算设施 由人工智能生成的编辑插图

本指南有助于实现的目标

  • 定义边界
  • 公开前过滤
  • 分离缓存
  • 执行撤销操作

快速检查

  • 单独的向量命名空间是否足够?
  • 权限是否应该显示在提示中?
  • 如何在测试中避免涉及机密文档?

分步指南

  1. 1

    定义边界

    为每个文档分配所有者、范围和访问规则。 OWASP 描述了由于向量存储权限错位而导致的跨上下文泄露。 我们提出的方法还将数据块和元数据视为受保护对象。

    交付成果:文档、组和范围清单。

  2. 2

    公开前过滤

    在数据块到达模型之前,在检索服务中强制执行授权。 涵盖向量搜索、词法搜索、图搜索和直接下载。 提示指令不能替代服务器端授权。

    交付成果:决策点和缺失身份行为。

  3. 3

    分离缓存

    清单保留的搜索结果、对话、引用和答案。 检查重用是否取决于相关的访问上下文。 仅凭索引字段指定客户并不能证明隔离性。

    交付成果:缓存键和分离场景。

  4. 4

    执行撤销操作

    使用非敏感测试文档,移除访问权限,删除文档并更改组。 重放更改前打开的对话。 衡量何时数据块、链接和保留答案失效。

    交付成果:带时间戳的撤销证据和漏洞。

  5. 5

    保留否定测试。

    分别以授权用户、其他用户组和未知身份提出相同的问题。 检查文件名、摘录、引用和日志。 在索引或连接器更改后重放测试;少数通过的案例仅能证明覆盖范围有限。

    交付成果:测试矩阵和更正负责人。

可重复使用的工作表

填写您已授权的观察结果。 这些字段是工作模板,而非观察结果。

字段待记录信息
文档/数据块所有者和范围
测试身份允许组、其他组、缺失身份
访问路径检索、引用、文件或缓存
结果预期、观察、日期和更正

虚构示例

示例情境

虚构示例:数据不代表客户或实际观察结果。 两个权限不同的部门使用同一助手,但助手检索共同文档库时没有采用一致的权限过滤。

决策及预期证据

创建权限不同的测试账户和虚构文档,检查检索结果、送入模型的片段、来源引用和拒绝回答。 在生成前阻止未授权内容暴露。要求模型遵守权限的提示不能代替访问控制。

区分机制

机制目的验证或限制
检索过滤器限制检索的数据块同时覆盖词法路由和直接链接
拒绝提示指导响应行为不将授权委托给它
答案缓存重用结果重用前检查权限上下文

管理指标

指标衡量内容首要行动
观察到的泄漏测试数据暴露在范围外阻止受影响的使用并检查原因
撤销延迟所有测试路由都被拒绝的时间名称缓存仍然可访问
路由覆盖率已执行的连接器和检索模式识别未测试的路径

常见错误

  • 同时覆盖词法路由和直接链接
  • 不将授权委托给它
  • 重用前检查权限上下文

常见问题解答

单独的向量命名空间是否足够?

它有助于数据分区,但缓存、文件链接和工具必须遵守相同的边界。

权限是否应该显示在提示中?

有用的上下文可能会到达模型;公开数据的服务必须强制执行访问决策。

如何在测试中避免涉及机密文档?

为每个小组创建带有不同标记的虚构哨兵文档,然后检查答案和引用。

RAG:访问权限、引用与缓存

此语言版本的详细参考说明以英语提供。

An accurate answer can disclose a forbidden document. Retrieval relevance, citation validity and access authorisation are separate checks. The service providing passages must enforce the current identity’s rights before exposing them to the model.

Fictional CIE teaching set: four technical identities, six documents and three states. It illustrates a proposed policy without querying your system, authenticating real users or measuring product security. OWASP references describe risk families; the scenarios, rules and numbers below are our examples.

References consulted on .

无人网络实验室中两个分离的文档存储区域 由人工智能生成的编辑插图
Two storage zones in an empty lab. The depicted separation establishes neither real isolation nor certification.

Explore the fictional document policy

Choose identity, document, state and access path. The result is the decision expected under this policy, not an observed test of your application. All four paths should enforce the same access decision.

Local browser calculation with no connection to an AI model, vector database or account. No free-text field, secret or document to send.

Matrix of 24 expected decisions

Ops has group ops; Alpha has alpha; Beta has beta. The unauthenticated identity has no access. Documents without an explicit rule are denied.

10 allowed accesses across 24 fictional combinations

1 · Initial rights
Identity / documentCross-team procedureAlpha noteBeta noteOps fileOld Alpha noteUnclassified document
Ops serviceAllowedAllowedAllowedAllowedAllowedDenied
Alpha serviceAllowedAllowedDeniedDeniedAllowedDenied
Beta serviceAllowedDeniedAllowedDeniedDeniedDenied
UnauthenticatedDeniedDeniedDeniedDeniedDeniedDenied

Three states with reproducible outcomes

Three states with reproducible outcomes
Fictional statePolicy changeAllowed accesses / 24
1 · Initial rightsOps has group ops; Alpha has alpha; Beta has beta. The unauthenticated identity has no access. Documents without an explicit rule are denied.10 / 24
2 · Alpha group removedAlpha remains authenticated but no longer has any required group. The cross-team procedure also requires one of ops, alpha or beta, so Alpha loses access to it as well. Ops and Beta groups are unchanged.7 / 24
3 · Group removed and old note deletedAlpha’s group removal persists. The old Alpha note is deleted and denied to every identity, including Ops. Other document rules stay unchanged.6 / 24

These counts describe a small closed set, not a security rate. State changes are instant in this demonstration. In production, measure the actual delay on every path; revoking a right cannot retroactively erase a copy already read or exported.

Twelve replay cases with positive controls and expected evidence

Fictional scenarios. Buttons populate the demonstration and run no penetration test. To assess an application, compare each expectation with an actual trace from an authorised environment using sentinel data.

Twelve replay cases with positive controls and expected evidence
Situation and referenceDemonstration inputDecision and evidence to retain
The group’s own document

OWASP · LLM08:2025 Vector and Embedding Weaknesses

Alpha service
Alpha note
1 · Initial rights
Vector retrieval

Allowed in this example

Positive control: retain the permitted fictional passage and service decision. A system denying everything does not pass the functional test.

Another group’s document

OWASP · LLM08:2025 Vector and Embedding Weaknesses

Beta service
Alpha note
1 · Initial rights
Vector retrieval

Denied in this example

Check that the passage, sensitive title and metadata are absent from data supplied to the model.

The secondary lexical branch

OWASP · LLM08:2025 Vector and Embedding Weaknesses

Beta service
Alpha note
1 · Initial rights
Lexical / hybrid retrieval

Denied in this example

Retain each branch’s decisions before fusion and the final result. No vector leak does not establish lexical coverage.

A known citation identifier

OWASP · API1:2023 Broken Object Level Authorization

Beta service
Alpha note
1 · Initial rights
Citation / file resolution

Denied in this example

Call citation resolution using the Beta test identity; retain the object denial, not just the absence of a link in the answer.

An old cached answer

OWASP · LLM08:2025 Vector and Embedding Weaknesses

Alpha service
Alpha note
2 · Alpha group removed
Cached answer or passage

Denied in this example

Create the answer before group removal and replay afterwards. Check that old passages are not returned under current rights.

The cross-team procedure after removal

OWASP · API1:2023 Broken Object Level Authorization

Alpha service
Cross-team procedure
2 · Alpha group removed
Vector retrieval

Denied in this example

This document requires an explicit group; remaining authenticated is insufficient. Retain the rule and membership change explaining the denial.

The unchanged group

OWASP · LLM08:2025 Vector and Embedding Weaknesses

Beta service
Beta note
2 · Alpha group removed
Lexical / hybrid retrieval

Allowed in this example

Beta positive control: confirm that revocation handling does not block another authorised group.

The deleted but remembered document

OWASP · API1:2023 Broken Object Level Authorization

Ops service
Old Alpha note
3 · Group removed and old note deleted
Cached answer or passage

Denied in this example

Try an old citation and cache after deletion. Record object state and refusal to return it; separately verify removal of copies under your policy.

A document without a rule

OWASP · API1:2023 Broken Object Level Authorization

Ops service
Unclassified document
1 · Initial rights
Vector retrieval

Denied in this example

Even Ops has no implicit privilege. Retain the handling of an unclassified document and the process for correcting its access rule.

Access without an authenticated identity

OWASP · API1:2023 Broken Object Level Authorization

Unauthenticated
Cross-team procedure
1 · Initial rights
Citation / file resolution

Denied in this example

Check citation paths and their errors: reserved content must not be exposed during a denied attempt.

A source claims higher authority

OWASP · LLM01:2025 Prompt Injection

Beta service
Ops file
1 · Initial rights
Cached answer or passage

Denied in this example

A sentence inside the document changes neither groups nor service rules. Retain the technical denial even if model wording is persuasive.

The Ops file remains allowed

OWASP · LLM06:2025 Excessive Agency

Ops service
Ops file
3 · Group removed and old note deleted
Citation / file resolution

Allowed in this example

Positive control after both changes: establish this specific access without granting Ops the unclassified or deleted document.

Document six technical boundaries

Collection
Retain document origin, version and status. Internal content can also carry hostile instructions. OWASP · LLM01:2025 Prompt Injection →
Authorisation
Check identity, object and groups in the service. Prompt text is not the permissions engine. OWASP · API1:2023 Broken Object Level Authorization →
Generation and rendering
Validate outputs for their destination: text, HTML, query or tool argument. A plausible answer is not directly executable input. OWASP · LLM05:2025 Improper Output Handling →
Tool action
Separate reading, proposing and modifying. Limit function, permission and autonomy to the task; read access does not authorise sending. OWASP · LLM06:2025 Excessive Agency →
Configuration
Keep secrets out of the system prompt. Confidentiality of its wording does not replace access controls. OWASP · LLM07:2025 System Prompt Leakage →
Consumption
Set request, duration and action limits, then exercise stopping and degraded operation with a demonstration budget. OWASP · LLM10:2025 Unbounded Consumption →

Useful traces without copying documents

Link test identifier, policy version, technical identity and effective groups, document identifier/version, access path, decision and timestamp. For revocation, add the change time and first observed denial per path. Use demonstration markers instead of secrets; restrict logs to necessary information and protect their access.

Continue with prompt injection testing →

Sources, editions and scope of the example

OWASP 2025 and API 2023 editions are explicitly identified. NIST AI 100-2 E2025 is a taxonomy published in March 2025; its page notes an April PDF correction and a June 2025 potential-update note. None certifies this simulator or your application.

RAG相关性与排序

此语言版本的详细参考说明以英语提供。

Relevance and permission need separate checks

A relevant document may be forbidden to the requester. Build the evaluation corpus within accessible scope and test denials independently of ranking scores.

  • Keep permissions and document versions with the test set.
  • Check revocation, deletion and citation paths before measuring relevance.
  • Do not use an nDCG improvement as evidence that permissions are respected.

Explore ranking measures and relevance judgments →

Stanford CS276 · Retrieval evaluation · 2019 course archive · PDF pp. 3, 5–6 · consulted 2026-10-23

NIST TREC · Reciprocal rank definition · Repository snapshot 35cf096ba6d5ae08ca4803c056b31ed61a56a6d4 · consulted 2026-10-23

官方参考文献

参考文献支持该方法。 请根据您的实际情况调整检查;它们并非认证。 原始参考文献标题和源文档可能使用其他语言。

参考资料查阅日期 .