Prasoon AI
ServicesInsights
Let’s talk
GOOD IDEAS DESERVE GREAT ENGINEERING.Explore the possibilities.

WHAT I BUILD

AI systems

Agents, private knowledge, and production AI.

SaaS platforms

Scalable software, from first release to growth.

HOW WE WORK

Services

Engineering expertise for your next challenge.

Industries

Solutions grounded in your business context.

IDEAS & PERSPECTIVES

Insights

Practical thinking on AI and architecture.

About my approach

Bridging research and production.

Available for select projectsDiscuss your project
All insights/AI Data Engineering

AI Data Engineering / Practical engineering

Secure Document Ingestion: From Untrusted Upload to Searchable Evidence

Build a quarantined ingestion pipeline with immutable object versions, isolated parsers, provenance, and atomic publication so uploaded documents cannot bypass your trust boundary.

P.
Prasoon ThakurAI systems architect
September 20, 20265 min read
THE ENGINEERING SERIESAI Data Engineering
UNTRUSTED INPUTsource.pdfVersion / 07
ISOLATED PARSERInspect.
Extract.
PUBLICATION MANIFESTVerified source. Traceable output.Only the accepted generation is searchable.
AI Data EngineeringIdeas, connected to implementation.
In this article6 sectionsContents +
  1. 01An upload is a request to enter a trust boundary
  2. 02Bind the upload session to an immutable object
  3. 03Quarantine before parsing
  4. 04Preserve provenance through every transformation
  5. 05Publish a manifest, not a stream of partial results
  6. 06Prove that failure cannot leak partial content

An upload is a request to enter a trust boundary

A document portal often begins with a signed upload URL and a queue job. That is sufficient for moving bytes. It is insufficient for deciding which bytes may become searchable, which parser may open them, and who may retrieve the extracted results.

Use an explicit ingestion state machine: requested, uploaded, quarantined, inspected, parsed, validated, published, or rejected. Every transition should name the exact object version, processing version, and authority under which it occurred. A display filename is not an object identity.

The architecture here is a proposed implementation pattern. It separates file safety from content trust: a document can be free of known malware and still contain false claims, confidential material, or instructions that an AI system must not obey.

Bind the upload session to an immutable object

Create the upload session after checking the user's permission, quota, allowed document types, and intended workspace. Generate the storage key on the server. Avoid using user-controlled path segments as authority, even when they look like workspace IDs.

S3 documents that a presigned URL can be reused until expiry and that uploading to an existing key replaces the object. A scan of one version therefore cannot authorize an arbitrary later upload to the same key. Record the accepted version identifier and checksum, or copy validated bytes into a separate immutable namespace before processing. S3 presigned URLs

When the client reports completion, verify the object server-side. Compare size and expected metadata, bind the exact version, and transition the session once. Duplicate completion requests should return the same ingestion identity.

Quarantine before parsing

OWASP recommends layered file checks rather than trusting an extension or client-provided content type. Its guidance includes limits, generated filenames, authorization, isolated storage, and content inspection. No individual check establishes that a file is harmless. OWASP file upload guidance

Run parsers in disposable workers with bounded CPU, memory, wall-clock time, output size, and temporary disk. Disable network access unless a specific document format genuinely requires it and the destination is controlled. Archive extraction also needs limits on nesting depth, file count, expanded bytes, and path traversal.

BoundaryRecordReject or defer when
Upload acceptanceObject version and byte countSession expired or quota exceeded
InspectionScanner version and resultUnsafe or inspection unavailable
ParsingParser version and resource useTimeout, malformed structure, or expansion limit
ValidationPage count and extraction qualityEmpty or materially incomplete output
PublicationManifest version and access policyAuthorization changed or source was deleted

An unavailable scanner should create a visible pending state, not quietly fall through to publication. The operational question is how long pending inspection may last and who receives the alert.

Preserve provenance through every transformation

Each extracted section should retain a source object version, page or location reference, parser version, and transformation ID. OCR text, normalized text, and embeddings are different derived artifacts. A checksum of the original PDF does not prove which parser produced the indexed text.

Use a processing key such as document version plus parser version plus indexing configuration. This makes retries reusable while allowing a deliberate reprocessing run after a parser upgrade. Keep the old searchable version available until the replacement passes validation, if the document's access policy still permits it.

Do not deduplicate across customers merely because file hashes match. A global existence check can expose whether another customer uploaded a particular document. Keep deduplication scoped to an authorized context or design a separate privacy-preserving process.

Publish a manifest, not a stream of partial results

Write derived objects and index records into an unpublished generation. Validate counts and references, then atomically change the document's active manifest. Readers resolve through that manifest and never see half an extraction.

Before activation, check that the document is still present and that its authorization version has not changed. If deletion or revocation occurred during processing, mark the generation abandoned and schedule cleanup. A worker's permission at job creation is not permanent permission to publish later.

The manifest should let operators answer which source, parser, extraction, and index generation produced a result. Keep status explanations understandable to the uploader: “inspection pending” and “could not extract readable text” are more useful than an internal worker exception.

Prove that failure cannot leak partial content

Test an upload overwritten after scanning, a parser crash after writing half the output, an expired upload session, and an access revocation during indexing. Submit a compressed archive with extreme expansion, a misleading extension, and a valid document with no extractable text.

Assert that unpublished generations never appear in search, that rejected files have bounded retention, and that retries do not create multiple active manifests. Measure publication delay separately from raw upload latency. The quality of this pipeline is determined by trustworthy searchable evidence, not the number of files accepted per second.

Frequently asked questions

Does a successful antivirus scan make a document safe for an AI system?

No. Scanning addresses some malicious-file risks. Parser isolation, resource limits, authorization, and treating extracted text as untrusted data remain separate requirements.

Can a presigned upload URL be treated as single use?

Not by default. S3 presigned URLs can be reused until expiry. Bind ingestion to an immutable object version and use application-level upload sessions to control acceptance.

About the author

Prasoon Thakur

Prasoon is an AI systems architect focused on reliable agents, retrieval, LLM operations, and scalable SaaS platforms. His work connects model behavior to the controls production teams need: evaluation, observability, security, and cost discipline.

GitHubUpwork profile

Need a reliable production system?

Turn the patterns in this guide into a scoped system design, delivery plan, and measurable reliability target.

Start a strategy session

Related insights

AI Procurement

AI Vendor Due Diligence: A Buyer’s Checklist

14 min read
Capacity Engineering

Backpressure by Design: Admission Control for Expensive APIs and Jobs

5 min read

Active Now • 24/7 Availability

Engaging with teams
from Silicon Valley to Singapore.

I operate as a high-availability resource. To maintain secure collaboration, all global engagements are managed via Upwork.

Discuss your project Direct collaboration through Upwork.

Global / Remote

24/7 Timezone Agnostic

Syncing with USA, Europe, UAE & Singapore

Secure Engagement

Top Rated Expert on Upwork

Prasoon AI

Thoughtful architecture.
Software built for the real world.

Based online. Working worldwide.

Explore

AI systemsSaaS platformsServicesIndustries

Discover

Engineering insightsMy approach

Connect

Upwork GitHub Open to project inquiries

© 2026 Prasoon Thakur

Independent thinking. Dependable engineering.Back to top ↑