Secure development

Building authorisation and provenance controls into RAG pipelines

Retrieval boundary: book, network, model arranged to illustrate building authorisation and provenance controls into rag pipelines.

Building authorisation and provenance controls into RAG pipelines connects a security requirement to the behaviour of a real feature. The relevant controls need to remain effective across custom code, integrations and the production configuration. Understanding authorisation and provenance controls into rag pipelines helps establish which security property the feature needs and where that property is actually enforced.

What does this involve?

Authorisation determines which resources and operations an established identity may use. It must be enforced where protected data is read or changed. User interface restrictions, obscure identifiers and documentation can help usability, but they do not replace the service's own permission decision.

Retrieval Augmented Generation (RAG) is now standard architecture for enterprise AI applications. By grounding language model responses in retrieved documents, RAG reduces hallucination and enables domain-specific knowledge. However, RAG introduces a unique attack surface that is distinct from both traditional web application vulnerabilities and standalone LLM risks.

RAG does not reduce risk -- it redistributes it across the data pipeline, creating new attack surfaces at every stage from ingestion to generation to output.

Why it matters

Consider a realistic failure: a retrieval index returns documents that the authenticated user could not obtain from the original application.

A missing check can expose another account's information or let an ordinary user perform a privileged action. The result should be described by the actual records and operations reached, including whether access crosses a customer or organisational boundary.

Implementation guidance should be applied to a real feature and its deployment. Framework defaults, custom handlers and integrated services all influence whether the intended protection remains effective.

How penetration testers check for it

Trace the relevant feature from its entry point to the data or operation it protects, including custom code and alternate paths.

  • Compare users with different roles and ownership relationships.
  • Exercise read, change, delete and alternate access paths.
  • Test nested resources, background processing and state changes.
  • Confirm rejection as well as the legitimate successful journey.

How to fix it

Use the appropriate maintained mechanisms and verify the result in the actual production configuration.

  • An insider modifies existing documents to include adversarial content that is not visible in normal rendering but is present in the extracted text.
  • Invisible Unicode characters or zero-width spaces encode hidden instructions that are not visible when reading the document but are processed by the language model.
  • Record a SHA-256 digest of each approved document in a separately controlled manifest. An attacker who can replace both a document and its stored digest can make a modified document pass the hash check.
  • Protect the manifest with a digital signature or a message authentication code (MAC), keeping signing or MAC keys outside the document store's write permissions. Verify the manifest's authenticity and the document's digest before retrieval; reject failures and alert the security team.
  • Enforce permission checks at each protected operation.
  • Maintain regression cases for unauthorised users and changed permissions.

A successful response alone does not prove unauthorised access. Establish whose resource was affected and what the caller was legitimately entitled to do.

Recheck the changed behaviour against the original failure conditions and the legitimate user journey. Keep enough evidence to show which release and configuration were verified, and include related entry points that depend on the same security decision.

Read about our methodology or contact pentested.com to discuss secure development and code review.

See your first test report this week.

Book a 30 minute demo. We will verify one of your targets with you and run a test against it, so you can judge the results on your own systems.

Book a demo