Beginner Lab
aws
Build a Malware Scanning Solution in AWS
Build, break and fix! This is the way to have fun when learning cybersecurity. In this beginner-friendly lab, we focus on building in AWS, and create a working prototype to scan for malicious files!
Scenario
Huge Logistics are about to launch an order upload portal, that allows clients to submit word and PDF documents for new container shipments. There's just one problem... there's no security yet and all documents are trusted! We need you to implement a security solution using native AWS services (and also VirusTotal) to scan the files and quarantine anything that is malicious.
- Non-Read-Only Filesystem: Ensure that all pods use a read-only filesystem to prevent unauthorized modifications.
- Privileged Escalation: Block pods where the AllowPrivilegeEscalation option in the security context is set to true, which can allow processes to gain additional privileges.
- Host Network Usage: Disallow the use of hostNetwork: true in pod specifications to prevent exposing the pod directly to the host network, reducing the risk of network-level attacks.
- Restrict HostPath Volumes: Restrict the use of hostPath volumes on a k8s pod.
Lab prerequisites
- Basic knowledge of AWS
Learning outcomes
- Combine multiple AWS services to create a working security solution
Real-world context
When external users upload content to sites and applications that use Amazon S3 storage, that content cannot be trusted and may need to be scanned for malware before being used by applications and opened by other users. This solution provides a fully serverless, cloudnative way to scan unknown objects in Amazon S3 using VirusTotal's extensive database of antivirus engines.
KEY TAKEAWAY
Any application that accepts file uploads is distributing files, whether it intends to or not. Scanning at the point of upload is a control you assemble from ordinary cloud services rather than a product you buy, and building it teaches you more about the platform than any single attack technique.
What this lab covers
You combine several AWS services into a working control: uploads land in storage, an event triggers processing, files are scanned, and the result determines whether they are released or quarantined.
The value is in the assembly. Each service is simple on its own, and connecting them correctly, with the right permissions and the right failure behavior, is the skill that transfers to every other piece of cloud engineering you do.
It assumes no prior AWS experience and suits engineers as much as security practitioners. If you have ever wondered what your platform team actually does with Lambda, this is a concrete example.
How event-driven security controls work
S3 emits events when objects are created, and those events can invoke a function directly or pass through a queue or topic. This is the mechanism behind most cloud automation, and once you have used it, a great deal of AWS architecture becomes legible.
The function receives the event, retrieves the object, evaluates it and acts on the outcome. The interesting design decisions are around failure: what happens when the scanner is slow, when the file is enormous, when processing fails, and whether the object is available to users while any of that is happening.
Quarantine is usually implemented as movement between buckets with different access, so an unscanned or failed object is never in a location the application serves from. That separation is what makes the control meaningful rather than advisory.
What you gain from building it yourself
You end up understanding the permission model properly. Wiring events, functions and buckets together forces you to work out which identity needs which permission on which resource, which is exactly the knowledge that prevents over-permissioned roles elsewhere.
You also learn where the failure modes live. A control that silently stops working is worse than no control, and building one makes the monitoring requirements obvious in a way that reading about them does not.
Commercial products exist for this and are often the right answer at scale. Having built the primitive version, you can evaluate them properly, because you know what the hard parts actually are and which claims matter.
Extending the pattern
The same architecture handles a wide range of tasks. Classifying uploads, extracting metadata, enforcing file type restrictions, redacting documents, generating thumbnails and validating structure all follow the identical event, process, decide, act shape.
It applies to security operations too. The pattern behind auto-remediation, where a configuration change emits an event that triggers a corrective function, is the one you have just built with a different trigger and a different action.
Cost and scale behavior are worth understanding while the example is small. Per-invocation pricing, concurrency limits and object size constraints all bite differently at volume, and they are much easier to reason about once you have run the thing.
Applying this at work
- Check whether your applications scan uploaded files at all, and where an unscanned file is reachable from before any evaluation happens.
- Confirm quarantined or unprocessed objects are stored somewhere your application cannot serve from.
- Add monitoring for the control itself, so a scanner that stops working raises an alert rather than silently passing everything.
- Review the permissions on your event-driven functions, which frequently hold more than the specific object access they need.
- Apply the same pattern to one manual security task you currently perform after the fact.
Frequently asked questions
Why scan files at upload rather than at download?
Because an unscanned file sitting in storage may be reachable by other paths, and because scanning once at ingest is cheaper and more predictable than scanning on every retrieval. It also means quarantine happens before anyone can access the object.
What happens if the scanner fails?
That is the central design decision. A control that releases files when processing fails provides very little assurance, so unprocessed objects should remain in a location the application cannot serve from until evaluation succeeds.
Should I build this or buy it?
At scale a commercial product is often the right answer. Building the primitive version first means you can evaluate those products properly, because you understand which parts are genuinely difficult.
Do I need my own AWS account to practice this?
No. The lab runs in a live AWS environment that Pwned Labs provisions for you, so there is nothing to set up and no risk to your own infrastructure.
Which certification covers this in depth?
The Amazon Cloud Red Team Professional (ACRTP) covers AWS attack and detection paths in full, including IAM abuse and privilege escalation, and is assessed hands-on in a live AWS account.
Cloud Security Training To Protect Your Business
Pwned Labs for Business gives your team access to dedicated business content, including labs and cyber ranges.
We also offer in-person or remote workshops, and our cloud penetration services are helping businesses become more secure!