AI-assisted upload inspection pipeline
Send each upload to a model on AI Inference from a Function on a Firewall, and deny a malicious file before the Application receives it.
This design serves teams that accept files from their users, such as PDFs in onboarding, claims, or support flows. A Firewall sends each upload to a Function that reads the file and asks a model on AI Inference whether it is malicious. A clean file continues to the Application, and a malicious one is refused before the Application receives it.
The Function writes a line for each flagged file and each error, and those lines stream to a SIEM through Data Stream. The SIEM or a person then adds a flagged sender to a Network List that a rule of the Firewall denies. A quarantine bucket in Object Storage can keep a refused file for an analyst to review.
The design implements the use case Screen file uploads for malicious content.
Architecture diagram
Solid arrows carry the request, dotted arrows carry the response, and thick arrows carry the log record, which runs apart from any request. Each label starts with the number of the dataflow step it belongs to.
Dataflow
- A user sends an HTTPS request that carries a PDF upload to a domain of a Workload. The data center nearest to the user receives it. The Workload’s deployment sets the Firewall that inspects the request and the Application behind it.
- DDoS Protection acts on the request before any rule of the Firewall runs. The Firewall then runs its rules in order, and the first rule that stops the request answers the user. A rule that uses Network Shield to deny the senders in a Network List answers
403. Where a rule applies a WAF rule set in Blocking, a request it blocks receives400. - A rule on the upload route runs the inspection Function through its Function Instance, with the Run Function behavior. The Function reads the request body as text, and decodes it first when the
Content-Typenames base64. A file whoseContent-Typestarts withimage/continues to the Application with no model call. - The Function calls the model with
Azion.AI.run, sending the content of the file and the prompt from the arguments of its Function Instance. The prompt in the use case asks the model to answertrueonly for malicious content, such as embedded scripts, andfalseotherwise. AI Inference runs the model and returns its answer to the Function in the same request, and that answer is the verdict. - The Function applies the verdict. On
true, it writes a warning line and calls the event method that itsactionargument names.denyanswers the user with403and Azion’s default error page, anddropcloses the request with no answer. Any other answer lets the upload continue to the Application, which forwards it to the origin and returns the response. - Real-Time Events keeps a record of each request that reaches the Firewall, with its status, and a record of each line the Function writes. Data Stream sends those lines to the endpoint that the SIEM reads, and Real-Time Metrics counts the invocations of Functions on Firewalls.
The rules before the Function decide from the sender’s address, the route, and the attack patterns that WAF scores. The Function then has a model read the file, and that model call is the one dependency the design adds to the request path. The Function waits while the model answers, so the time the model takes adds to the response time of each upload.
The design fails open. When the model call or the parsing throws, the Function writes an error line and lets the upload continue. A model that stops answering therefore shows as error lines, not as refused uploads.
A refused upload stops at the Firewall, before the Application and the origin. A flagged sender joins the Network List only after the request, from the verdict lines.
Components
- Firewall: routes each upload to the Function before the Application receives it. The deny rule on the Network List of senders sits above the rule that runs the Function, so a listed sender never reaches the model. The rule that runs the Function matches only the upload route, such as
/upload, so every other route skips the model call. A WAF rule set in Blocking that scores the upload route refuses every body larger than 131,072 bytes with400. - Functions: runs the inspection code as a Function whose execution environment is
firewall, through a Function Instance on the Firewall. It receives the request, reads the PDF, calls the model withAzion.AI.run, and applies the outcome in the same request. The outcome is an event method:continue,deny,drop, orrespondWith, which answers with a response that the code builds. The Function that the use case builds refuses withdenyordrop, so a refused upload gets the fixed403page or no answer. - AI Inference: runs the model that classifies the content. A Function on a Firewall calls
Azion.AI.runas a Function on an Application does, and the answer returns in the same request. The model id, from AI models, and the prompt sit in the arguments of the Function Instance, so the policy changes with no new code. A change to those arguments reaches traffic in up to a few minutes, with no duration guaranteed. - Object Storage: holds the quarantine bucket, where a refused upload can be kept for an analyst to review. The Function that the use case builds denies the file and writes it to no bucket.
- Network Shield: holds the sender blocklist, a Network List that a deny rule reads through the Network criterion. A flagged sender is then refused on every route of the Workload,
/uploadincluded. The Function logs the verdict and not the address, so the SIEM or a person adds the address that the verdict’s request ID leads to. Each entry can carry a due date, which ends the block at the next write of the list’s items. - Data Stream: sends the lines the Function writes, the Functions data source, to the endpoint that the SIEM reads. The Function that the use case builds writes a warning line,
[AI] true, for each refused upload, and an error line for each failure. Each line carries the$request_idof its request. A clean file adds no line. - SIEM (integration): correlates the verdicts with the request records and the team’s other sources, and turns a verdict into a blocklist entry. For a playbook that writes the list, refer to SIEM-driven firewall mitigation loop.
Implementation
- Screen file uploads for malicious content - builds this design end to end: the sender blocklist, the inspection Function, and the stream of verdict lines.
- Scan file uploads with an AI Inference firewall function - creates the inspection Function and the Firewall rule that runs it on the upload route.
- Block addresses until a date - creates a dated entry in a Network List and the Firewall rule that denies it.
- Change the order of Firewall rules - moves the deny rule on the sender list above the rule that runs the inspection Function.
- Update a Network List from an automation - adds each flagged sender to the list from a SIEM playbook or a script.
- Debug functions with Data Stream - sends the lines the Function writes, with their level and request ID, to the endpoint that the SIEM reads.