Malware in Coding Tests
There's a moment in every hiring process where a candidate is asked to prove they can code, and the standard way to do that is to send them a repository, a zip file, a package, or a link to an "assessment environment" and ask them to get it running.
That moment is one of the most reliable delivery mechanisms in modern attacks, and the reason is not technical, it's contextual, because a candidate who has spent three weeks interviewing, who wants the job, and who has a deadline is a person who will clone a repository and run npm install without asking whether the repository is safe.
This isn't about careless developers, and it's about a workflow where running untrusted code is the task itself, which means every control built on "don't run untrusted code" collapses at exactly the point it's needed.
Important Disclaimer
This article is intended for educational and defensive purposes only, and it describes a general attack pattern and defensive practices rather than specific incidents, campaigns, or organisations. It contains no claims about particular threat actors or published advisories. Every command shown is read-only and intended for systems you own or administer.
Never run an assessment you suspect is malicious to "see what happens," and never analyse suspicious code outside an isolated environment. The author assumes no liability for missed detections, data exposure, business outcomes, or damages resulting from the use or misuse of this information.
Why the Hiring Pipeline Is a Target
Attacks delivered through hiring work because they exploit three things that are hard to change.
- The relationship is asymmetric. A recruiter approaches a candidate, the candidate wants to make a good impression, and questioning the format of an assessment feels like a risk to the opportunity. An attacker only needs the candidate to be polite.
- The code arrives pre-trusted. A repository from a company is assumed to be the company's code, and nobody reviews a prospective employer's codebase for malicious content, because the entire premise of the exercise is that you're being evaluated rather than evaluating.
- Verification is awkward. Asking "can you confirm this zip file is from your company, and can you tell me what it does on install?" is a reasonable question that almost nobody asks, because it implies distrust at the worst possible moment.
The combination means the attacker doesn't need a vulnerability, a zero-day, or a convincing pretext, because the pretext is a job.
The Delivery Vehicles, and What Each One Looks Like
The mechanism varies, and each vehicle has a different set of tells.
- The take-home repository is the most common, and it arrives as a GitHub or GitLab link with a task description, often with a deadline. The malicious component is usually not in the code the candidate is meant to read, and it's in the scaffolding around it, which means configuration files, scripts, and dependencies.
- The zip file or archive is the cruder version and often the more obvious one, because an archive can contain an executable disguised as a setup step, and the instruction to "run the setup script first" is the whole attack.
- The assessment platform is the version that looks safest and isn't, because it asks the candidate to install a proctoring client, a screen recorder, or a browser extension, and the install is the payload delivery rather than the assessment itself.
- The package dependency is the subtlest, because the repository is clean, the code is genuinely what it claims to be, and the attack is in a dependency that resolves to a malicious version or a name that was registered specifically to be depended upon.
- The "environment setup" instructions are the version that requires no code at all, because a README can ask the candidate to run a command, install a tool, or add a package registry entry, and none of those require modifying anything in the repository itself.
The Technical Mechanics That Actually Execute
The reason this works is that the modern development toolchain executes code as a side effect of ordinary commands, and each of those side effects is a feature.
- Package manager lifecycle scripts are the biggest one, because installing dependencies can run arbitrary commands defined by the dependency, and the candidate's command is npm install rather than run this script, which means the execution happens under a command they consider safe.
- Version control hooks are the second, because a repository can specify scripts that run on commit, on checkout, on merge, or on operations the candidate performs as part of the task, and those hooks are configuration rather than obvious code.
- Editor and IDE workspace settings are the third, because opening a project can cause tooling to start, extensions to load, tasks to become available, and language servers to run, and the candidate's action is "open the folder."
- Installers and setup utilities are the fourth and the most traditional, because a proctoring client or a "coding environment" installer is software, and software installs whatever it was built to install.
- Container and devcontainer definitions are the fifth and the newest, because a repository can specify a container image to build and run, and building an image can execute instructions from the repository, which means the isolation the container was meant to provide happens after the code has already run.
Why the Obvious Advice Doesn't Work
The standard guidance is "don't run untrusted code," and it fails here because the entire assessment is a request to run untrusted code, and the candidate who refuses every take-home assignment doesn't get hired.
The second standard guidance is "use a virtual machine," and that helps with the blast radius but not with the outcome, because a VM that contains your email session, your browser profile, and your personal accounts is not meaningfully isolated, and a VM that contains nothing is not the machine a candidate actually uses.
The third is "read the code before running it," and that's genuinely good advice that most candidates can't follow, because the malicious component is in a dependency tree hundreds of packages deep, or in a lifecycle script that runs before the candidate has finished reading the README.
So the practical controls have to be about how you run it rather than whether you do.
Running an Assessment Safely
The realistic approach is to assume the assessment may be hostile and design the environment accordingly, so that a malicious payload has nothing valuable to reach.
- Use a disposable environment with no credentials in it. A throwaway container or a freshly provisioned VM with no browser sessions, no saved passwords, no SSH keys, no cloud CLI caches, and no access to your personal or work accounts, because the payload's objective is almost always credential theft and an environment without credentials has nothing to steal.
- Install dependencies with lifecycle scripts disabled where possible. Many package managers allow you to skip install scripts or run them in an explicit mode, which converts npm install from an execution event into a download, and you can review what the scripts would have done afterwards.
- Do not open the project in your normal editor profile. A separate editor profile or a fresh installation means workspace settings, extensions, and tasks from the repository can't influence your day-to-day tooling, and that separation is what prevents the "opening a folder" vector.
- Run it as a low-privilege user with no home directory contents. An account whose home directory contains nothing but the project means a filesystem-walking payload finds nothing worth taking.
- Never sign in to anything from inside the environment. The most common objective of this class of malware is session theft, so the single most effective rule is that no browser session, no email login, and no password manager unlock happens inside the assessment environment.
The Signals That Suggest an Assessment Is Hostile
Most of these are cheap to check and they're all visible before you run anything.
- The recruiter's domain doesn't match the company. Look at the email address rather than the display name, and be suspicious of a slightly different domain, a free mail provider, or a domain registered recently.
- The assessment arrives before any interview. A company that sends a technical task to someone it has never spoken to is either disorganised or not a company, and the pattern of skipping straight to code is a recognised tell.
- The communication channel is unusual. Offers to continue over a personal messaging app rather than corporate email are common in these campaigns, because it avoids the corporate mail filter.
- The instructions emphasise running something before reading anything. A README that says to run a setup script, install a tool, or add a registry before doing anything else is asking you to skip the review.
- The repository contains configuration you weren't asked to look at. Setup scripts, lifecycle hooks, container definitions, and editor workspace settings are the parts that execute, and they're usually not part of the task.
- The package names are almost right. A dependency that's one character off a well-known package, or a package with very few downloads, is the supply chain version of this attack.
- The task requires installing a specific client. Genuine proctoring does exist, and a request to install an unlisted executable from a link in an email deserves independent verification through the company's official careers page.
What Employers Should Do
If you run hiring, the controls here are as much about your reputation as about your candidates' security, because a candidate who receives a suspicious assessment from your domain will assume your company is compromised.
- State your process on your official careers page. Publish what candidates should expect, which domains your emails come from, what the assessment involves, and what it will never ask them to install, so a candidate can verify an approach independently.
- Never require an unlisted executable. Prefer browser-based environments, or a repository the candidate can inspect, and if a client is genuinely necessary, link it from your official domain and say so in advance.
- Keep assessment repositories minimal. A task that needs three dependencies is safer than one that needs a full framework, because every dependency is a lifecycle script a candidate has to trust.
- Document the setup and explain the execution. A README that says "this runs a build script that compiles the code" is honest, and one that says "run setup first" is indistinguishable from an attack.
Two Scenarios
Scenario 1: The Assessment Before the Interview
The Setup
A developer receives a message from a recruiter about a senior role at a company they recognise, and the recruiter suggests moving quickly because the team is hiring this week, then sends a zip file with a coding task and a note to run the setup script before starting.
What Happened
The script downloads a small binary, executes it, and the binary reads the browser's saved credential and session stores and uploads them, and the developer notices nothing because the task itself works and they complete it in ninety minutes.
The Result
The attacker replays the stolen sessions and reaches email and file storage without a password prompt, and the developer discovers the incident days later when a colleague receives an unusual message from their account, and the assessment repository is taken offline by the platform shortly afterwards.
The Lesson
The recruiter's domain was a lookalike, the interview never happened, and the only control that would have helped was running the task in an environment with no credentials to steal.
Scenario 2: The Disposable Environment
The Setup
Another developer receives a similar approach and follows a personal rule, which is that every take-home assignment runs in a fresh container with no browser, no credentials, no keys, and no access to anything but the project directory.
What Happened
The setup script runs and attempts to read credential paths that don't exist, tries to establish a connection that the container's egress rules block, and writes a file to a directory that is discarded when the container stops, and the developer completes the task and submits it.
The Result
Nothing is stolen, the container is destroyed rather than cleaned, and the developer reports the approach to the company being impersonated, who confirm they have no record of it and begin warning other candidates.
The Lesson
The environment design did all the work, because a payload with nothing to steal and nowhere to send it is a failed attack rather than an incident.
How to Spot a Hostile Assessment
- The recruiter's domain doesn't exactly match the company. Check the address, not the display name.
- No interview before the code. Real processes talk to you first.
- Communication moves to a personal messaging app. It avoids corporate filtering.
- A setup script must be run before you read anything. That's a request to skip review.
- A package name is one character off a popular library. That's typosquatting.
- An executable must be installed for the assessment. Verify it independently through official channels.
- The repository has container, hook, or workspace configuration outside the task. That's where the execution lives.
- The deadline is unusually tight. Urgency is the mechanism that suppresses questions.
Quick Reference: Vehicle to Risk
|
Vehicle |
What Executes |
Primary Control |
|
Take-home repository |
Package lifecycle scripts, hooks |
Disable install scripts, low-privilege user |
|
Zip or archive |
Setup executables |
Never run outside isolated environment |
|
Assessment platform client |
Installer |
Verify independently, prefer browser-based |
|
Package dependency |
Lifecycle scripts, typosquats |
Verify names and download counts |
|
README instructions |
Whatever it tells you to run |
Treat as untrusted as the code |
|
Editor workspace settings |
Extensions, tasks, language servers |
Separate editor profile |
|
Devcontainer definition |
Build-time instructions |
Assume build executes before isolation |
The Bottom Line
Embedding malware in coding tests works because the hiring process asks candidates to run untrusted code and simultaneously discourages them from questioning it, which means the technical controls have to compensate for a social situation that isn't going to change.
The practical position for candidates is to run every assessment in a disposable environment with no credentials, no browser sessions, and no keys, to disable install scripts where possible, and to ask the recruiter to confirm the assessment through the company's official domain, because a legitimate employer will not be offended and an impersonator will.
The practical position for employers is to publish your process, keep assessments minimal, never require an unlisted executable, and make the setup instructions explain what they do, because your candidates' security posture is now part of your hiring brand whether you planned for that or not.
So set up one disposable environment this week, before you need it, because the moment you're offered a role you want is the worst possible time to be deciding how to isolate a repository.
FAQ
How is malware hidden in a coding test?
Most often in the scaffolding rather than the task itself, which means package lifecycle scripts, version control hooks, editor workspace settings, container definitions, or a setup script the candidate is instructed to run before reading anything.
Why do candidates fall for these assessments?
Because the process is designed to make running code the task, the candidate wants the role, and questioning the format feels like a risk to the opportunity, so the social situation suppresses exactly the scepticism that would help.
Is npm install dangerous?
It can be, because package installation may execute lifecycle scripts defined by dependencies, which means the command a developer considers routine can run arbitrary code before anything has been reviewed.
What is the safest way to run an untrusted repository?
In a disposable container or freshly provisioned virtual machine with no browser sessions, no saved credentials, no SSH keys, no cloud CLI caches, and no access to your personal or work accounts, so that a payload has nothing to steal and nowhere to send it.
Can a virtual machine protect me?
It reduces the blast radius but doesn't automatically protect you, because a VM that contains your email session, your browser profile, or your cloud credentials is not meaningfully isolated, and the isolation depends on what you put inside it.
How do I verify a recruiter is legitimate?
Check the email domain against the company's official careers page rather than the display name, look for a real interview before any coding task, and independently confirm the assessment through a contact detail published on the company's own site.
Should I report a suspicious assessment?
Yes, to the company being impersonated through their published security or careers contact, because they can warn other candidates and it's often the first indication they have that their brand is being used.
What should employers change about assessments?
Publish your process so candidates can verify it, keep dependencies minimal, prefer browser-based environments, never require an unlisted executable, and write setup instructions that explain what they execute rather than instructing candidates to run something first.