Skip to content
CaseOps is onboarding its first litigation chambers directly.Book a demo
Security
CASEOPS
Log inBook a demo
Demo
  1. Hamza Liaqat
  2. /
  3. Case studies
Case study 04 · Distributed systems and backend engineering

Asynchronous malware scanning for public file submissions

Building an event-driven malware scanning pipeline on AWS.

Public file submissions needed malware scanning without slowing down the upload experience. Hamza engineered an event-driven AWS pipeline using S3, SQS, ClamAV and Celery, separating untrusted uploads from final storage and routing detected threats into quarantine.

Role
Software and backend engineer
Client
Department of Agriculture, Fisheries and Forestry (DAFF), Australia
Engagement
GoSource Australia (contract)
Focus
Event-driven architecture, distributed systems, asynchronous malware scanning
Stack
Python · Django · Celery · Amazon S3 · Amazon SQS · ClamAV · Event-driven architecture · Background workers

The problem

The Department operated a platform that accepted submissions from the public, and a submission could carry attachments: images, PDFs and other media. Every one of those files came from outside and had to be treated as untrusted until it had been scanned for malware.

Scanning inside the upload request would tie every response to however long the antivirus check took. Writing files straight into the application’s storage and scanning them later would put unscanned content inside the boundary the application trusts. Neither was acceptable.

The design

Hamza engineered a pipeline that separates three steps a simpler design would fuse together: accepting a file, deciding whether it is safe, and admitting it to the application.

Django accepts the submission and responds straight away. From there the file moves through dedicated S3 buckets, each with a single responsibility, and every hand-off is an S3 object-created event delivered through Amazon SQS to the component that acts next. A separate worker running ClamAV does the scanning; a Celery task in the Django backend does the final promotion.

Event-driven malware-scanning pipelineA submitter uploads a file to the Django submission API, which returns HTTP 200 without waiting for the scan. The file is stored in an Amazon S3 staging bucket, whose ObjectCreated event is published to an Amazon SQS scan queue. A scan worker consumes the message, retrieves the file and scans it with ClamAV. If the file is clean, the worker moves it to an S3 clean bucket; that object’s creation notifies SQS, a Celery task in the Django backend consumes the notification and promotes the file into the final storage bucket. If malware is detected, the worker moves the file to a quarantine bucket; an SQS notification is consumed by the Django backend, and the application UI shows the file as quarantined.1ACCEPT THE UPLOADA synchronous request, then an S3 event hand-offSYNCHRONOUS REQUESTEVENT HAND-OFFPUBLICSubmitterImages, PDFs, mediaDJANGOSubmission APIAccepts the uploadAMAZON S3Staging bucketUnscanned filesAMAZON SQSScan queueObjectCreated eventssubmits fileHTTP 200stores uploadObjectCreatedThe response does not wait for the scan.HTTP 200 acknowledges the submission. It does not clear the file.the scan worker consumes each message2SCAN AND ROUTEAsynchronous, after the responseSCAN WORKERClamAVAn AWS-hosted worker.Retrieves each stagedfile and scans it.Moves each file byits scan result.cleanmalwaredetectedAMAZON S3Clean bucketPassed the scanAMAZON SQSNotificationObjectCreated eventCELERYPromotion taskIn the Django backendAMAZON S3Final storageApplication bucketnotifiesconsumedpromotesAMAZON S3QuarantineIsolated bucketAMAZON SQSNotificationQuarantine eventDJANGOStatus processingBackend consumerAPPLICATION UIQuarantinedStatus displayednotifiesconsumedsurfaces
  1. Synchronous request

    Public

    Submitter

    Images, PDFs, media

    submits file

    HTTP 200

    Django

    Submission API

    Accepts the upload

    The response does not wait for the scan.

    HTTP 200 acknowledges the submission. It does not clear the file.

  2. stores upload

    Amazon S3

    Staging bucket

    Unscanned files

  3. ObjectCreated

    Amazon SQS

    Scan queue

    ObjectCreated events

  4. the scan worker consumes each message

    Scan worker

    ClamAV

    An AWS-hosted worker retrieves and scans each staged file, then moves it by the result.

    1. Clean

      1. Amazon S3

        Clean bucket

        Passed the scan

      2. notifies

        Amazon SQS

        Notification

        ObjectCreated event

      3. consumed

        Celery

        Promotion task

        In the Django backend

      4. promotes

        Amazon S3

        Final storage

        Application bucket

    2. Malware detected

      1. Amazon S3

        Quarantine

        Isolated bucket

      2. notifies

        Amazon SQS

        Notification

        Quarantine event

      3. consumed

        Django

        Status processing

        Backend consumer

      4. surfaces

        Application UI

        Quarantined

        Status displayed

  • Upload and event flow
  • HTTP response
  • Clean path
  • Malware path
Explanatory architectural reconstruction, drawn for this page from the pipeline’s design. It is not a screenshot or copy of the Department’s infrastructure, and it leaves out hosting, naming and configuration details.

How the pipeline worked

  1. 01

    Accept, then acknowledge

    A submitter uploads a file to the Django backend, which accepts the submission and returns HTTP 200 without waiting for antivirus processing. The response acknowledges receipt. It does not mean the file has been scanned or approved.

  2. 02

    Stage and notify

    The uploaded object lands in a dedicated S3 staging bucket. Its creation raises an S3 ObjectCreated event, which publishes a notification to an Amazon SQS queue.

  3. 03

    Scan in an independent worker

    An AWS-hosted worker consumes that queue, retrieves the staged file and scans it with ClamAV. Scanning runs entirely outside the Django request cycle.

  4. 04

    Clean: promote through an intermediate bucket

    When the scan is clean, the worker moves the file to a separate S3 clean bucket. Creating that object sends another SQS notification, which a Celery task in the Django backend consumes before moving the verified file into the application’s final storage bucket.

  5. 05

    Malware detected: quarantine and report

    When ClamAV identifies malware, the worker moves the file into a quarantine bucket instead. The quarantine path also produces an SQS notification, which the backend consumes so the application can show the file’s quarantined status in its UI.

Why the architecture matters

An immediate response keeps the upload experience independent of scanning. The submitter’s request finishes once the submission is accepted, and how long a scan takes no longer affects it.

S3 events and SQS decouple ingestion from scanning. Django does not call the scanner, and the scanner does not call Django: each side reacts to an object appearing in a bucket, with a queue holding the work in between. The worker and the backend operate independently, each consuming its own notifications.

Running ClamAV in its own AWS-hosted worker also keeps antivirus software and its workload out of the web application.

Trust boundaries, made explicit

Each bucket marks a state, not just a location. Staging holds files nobody has vouched for. The clean bucket holds files that passed the scan. Final storage holds only files that passed the scan and were then promoted by the backend. Quarantine holds files the scanner flagged.

The intermediate clean bucket is what keeps the scanner out of application storage. The worker’s job ends once it has placed a file in clean or quarantine; the move into final storage is made by the Django backend, in response to its own notification. Clearance by the scanner and admission by the application stay separate steps.

Files with detected malware take the other branch. They are moved into quarantine and do not enter application storage through this pipeline.

The invariant

Only files cleared by the scan, then promoted by the backend, reach final application storage through this pipeline.

Outside final storage · untrusted until cleared

Inside the application

1Untrusted upload

Staging bucket

Accepted, not yet scanned. Held outside final storage.

2Antivirus inspection

ClamAV worker

Scans each staged file and decides which path it takes.

3Clean intermediate

Clean bucket

Passed the scan. Waits for the backend to promote it.

5Quarantine

Quarantine bucket

Malware detected. The file stays here, isolated from application storage.

promoted by the backend
status only

4Final application storage

Final storage bucket

Receives files only from the clean path, by backend promotion.

Application UI

Quarantined status

The backend consumes the notification; the UI shows the file as quarantined.

Outside final storage · untrusted until cleared

1Untrusted upload

Staging bucket

Accepted, not yet scanned. Held outside final storage.

queued for scanning

2Antivirus inspection

ClamAV worker

Scans each staged file and decides which path it takes.

3Clean intermediate

Clean bucket

Passed the scan. Waits for the backend to promote it.

5Quarantine

Quarantine bucket

Malware detected. The file stays here, isolated from application storage.

promoted by the backend

status only

Inside the application

4Final application storage

Final storage bucket

Receives files only from the clean path, by backend promotion.

Application UI

Quarantined status

The backend consumes the notification; the UI shows the file as quarantined.

Explanatory diagram of the file lifecycle, drawn for this page. The boundary is the line between files the pipeline has not cleared and the application’s final storage.

Results the application can show

Asynchronous processing still has to come back to the person who submitted the file. Both branches end in a notification the backend consumes: on the clean path, to promote the file; on the malware path, so the application can display the file as quarantined rather than leave its status unexplained.

The outcome

  • Submissions accepted without waiting for a malware scan
  • Clean files promoted into final application storage through an intermediate clean bucket
  • Files with detected malware isolated in a quarantine bucket, outside application storage
  • Quarantined status surfaced in the application’s UI
  • Ingestion, scanning and promotion decoupled through S3 events, SQS and background workers

What it shows

Designing and delivering production backend systems with AWS messaging, storage events and background workers, and making a security-sensitive process asynchronous without blurring the line between checked and unchecked files.

Next case study · Technical leadership and product judgement

From a legacy Django form to a modern government submission experience.

Read the case study
Back to Hamza Liaqat’s portfolio
CASEOPS

Turn case files into AI workspaces for legal work — source-backed, reviewable, built for chambers.

Product

Platform overviewDraftingCaseOps MobileCase File IntakeDossier working briefLegal workSource verificationHearings & order sheetsChamber workspace

Solutions

Litigation chambersSecurity & trustPricing

Company

AboutTechnology & ResearchFAQBlogContact

Legal

Privacy policyTerms of service

© 2025 CaseOps. All rights reserved.

Built for lawyer review, not blind reliance.

CaseOps is a member of the NVIDIA Inception program. NVIDIA and the NVIDIA logo are trademarks and/or registered trademarks of NVIDIA Corporation in the U.S. and other countries.