Quick revision
The short answer
Four services with the same bug means the problem is the organisation, not four developers, so the fix has to make the safe way the easy way. I would ship one vetted extraction component with safe defaults and attack tests, run extraction in isolated workers with resource limits, add static analysis rules to every repository's CI so new unchecked code is caught, put the pattern into training and design reviews, and track the four existing fixes to closure with tests that reproduce the attacks.
What to remember
In this answer, we treated four identical findings as a sign that the unsafe path was the easy path. We fixed the four services by risk with tests that reproduce the attacks, built one owned extraction component with safe defaults, moved untrusted extraction to isolated workers with resource limits, added CodeQL or Semgrep rules to every repository's CI, put the pattern into training and review checklists, and measured adoption and findings until the problem was gone.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Four services with the same bug means the problem is the organisation, not four developers, so the fix has to make the safe way the easy way. I would ship one vetted extraction component with safe defaults and attack tests, run extraction in isolated workers with resource limits, add static analysis rules to every repository's CI so new unchecked code is caught, put the pattern into training and design reviews, and track the four existing fixes to closure with tests that reproduce the attacks.
Why this question is asked
Security findings are rarely unique. When the same vulnerability appears in four codebases, it will appear in a fifth next quarter unless something structural changes, and fixing each one by hand leaves the organisation exactly as exposed to the next service. Interviewers ask this leadership question to hear how we move from patching to prevention, how we balance mandates against teams' autonomy, and how we prove the risk is gone. In this answer, we will recap the two attacks briefly, look at why the bug repeats, then go through the response: fix the four services, provide a shared component, isolate extraction, add automated detection, teach the pattern, and measure the outcome.
1A Quick Recap of the Two Attacks
Zip Slip happens when code turns an archive entry's name into a file path without checking it. An entry named ../../../etc/cron.d/job lands outside the extraction folder and can overwrite configuration, scripts or keys. A zip bomb is a small archive that expands to an enormous size, gigabytes or more, filling the disk or exhausting memory. Both have simple, well-known defences: normalise the resolved path and check it stays inside the target, and count real bytes and entries while extracting against hard limits.
So the knowledge exists. The question for a leader is why four teams did not apply it.
2Why the Same Bug Appears in Four Places
Usually the answer is that the easiest code to write is the unsafe one. The standard library makes extraction a few lines, popular examples skip the checks, and nothing in the build complains. Each team copied a working snippet, tested it with friendly files, and moved on. Nobody owned "how we handle archives", so there was no shared answer to reach for.
That diagnosis shapes the fix. Telling people to be more careful changes little. Changing what the easy path is, and adding a safety net that catches the unsafe path automatically, changes a lot. I would say this explicitly in the incident review, so the four teams hear that the fix is about the system, not about blame.
3Fix the Four Services Now, With Proof
The existing exposure comes first. Each service gets an owner and a date, sized by risk: a service that extracts files from anonymous users to a shared volume is fixed this week; an internal tool used by administrators can take a little longer. Each fix lands with tests that reproduce the attacks, so we know it works and it cannot silently regress: an archive with a ../ entry, one with an absolute path, a small archive that expands past the limit, and one with tens of thousands of empty entries. Security re-tests each service before the finding is closed, and the status is tracked on one page visible to engineering leadership until all four are done.
4One Vetted Extraction Component
Next, we build the safe path once. A small platform library, owned by a named team, offers a single call such as ArchiveExtractor.extract(input, targetDir, limits), with safe defaults: path normalisation and containment checks, rejection of absolute paths and symbolic links, limits on total uncompressed bytes, entry count, per-entry size and compression ratio, all counted while copying, and cleanup of partial output on failure. Its own test suite contains the attack archives. Teams can raise limits through configuration with a reason, but cannot turn the checks off.
The component has to be easier than the snippet, or teams will not adopt it. That means good documentation, a one-line Spring Boot starter, sensible defaults for common cases such as document uploads, and a migration guide that turns each of the four fixes into a small change.
- Training and design review checklistpeople recognise the pattern
- Static analysis in every repository's CIunchecked entry names fail the build
- Shared extraction componentsafe defaults, attack tests, owned by a team
- Isolated extraction workersquotas, no network, short time limits
4 layers, from the top down. Step through them one at a time.
Each layer catches what the one above misses; the bottom layer limits damage if every check fails.
5Isolate Extraction From Request Handling
Even a good library can have a bug, and a zip bomb that slips through should not take down the service that answers customers. So extraction of untrusted archives moves to a separate worker: the request service stores the upload and queues a job, and the worker extracts it in a container with a memory limit, a disk quota on a scratch volume, no network access and a time limit. If something goes wrong, the worker dies and the job fails; the customer-facing service keeps running. This also gives security one place to monitor and harden.
6Automated Detection in Every Repository
To stop the fifth occurrence, we add static analysis that recognises the pattern. CodeQL ships queries for Zip Slip, and a short Semgrep rule can flag entry names used as paths without going through the shared component. The rule runs in CI across all repositories, starts as a warning while existing code is cleaned up, and becomes a blocking check after a fixed date.
The rule will have false positives at first, and that is acceptable: the message points people to the component, which is the outcome we want. We review the hit rate after a month and refine it.
7Teach It, and Measure It
Finally the human layer. The pattern goes into secure coding training with the real examples from our four services, anonymised, and into the design review checklist: "Does this service accept archives or other compressed input? Which component handles it?" New services that handle uploads get a short security review.
We measure whether it worked: all four services fixed and re-tested, the number of repositories using the shared component, static analysis findings over time trending to zero, and no new archive-related findings in the next penetration test. Those numbers go into the security report to leadership, which also justifies the time spent.
- Fix the four services by riskattack tests, security re-test
- Publish the shared extraction componentsafe defaults, easy adoption
- Move untrusted extraction to isolated workerslimits contain any miss
- Turn on CI static analysis, then make it blockingstops the fifth case
- Train, add to review checklists, measurefindings trend to zero
5 steps in order. Play them, or step through them one at a time.
8Follow-up questions
Would you mandate the shared component?
For new code handling untrusted archives, yes, enforced by the CI rule. For existing code I would require the safety properties, tested, and strongly recommend the component, because forcing an immediate rewrite of every edge case creates resistance without much extra safety.
Who should own the component?
A platform or security engineering team with time allocated for it, not whichever team wrote it first. Unowned shared libraries rot; an owner keeps dependencies patched, reviews limit changes and answers questions.
How do you keep this from becoming a one-off campaign?
By leaving permanent mechanisms behind: the blocking CI rule, the review checklist question and the component's tests. Those keep working after everyone has forgotten the incident.
9Conclusion
In this answer, we treated four identical findings as a sign that the unsafe path was the easy path. We fixed the four services by risk with tests that reproduce the attacks, built one owned extraction component with safe defaults, moved untrusted extraction to isolated workers with resource limits, added CodeQL or Semgrep rules to every repository's CI, put the pattern into training and review checklists, and measured adoption and findings until the problem was gone.
Open with
Four services with the same bug tells me the unsafe way is the easy way, so I would fix the system, not just the four code paths. First, the existing exposure: each service gets an owner and a date based on risk, and each fix comes with tests that reproduce Zip Slip and zip bombs, an entry with dot-dot segments, an absolute path, a high-ratio archive and one with thousands of entries, and security re-tests before we close it.
Then, if they want more
Second, I would have a platform team build one extraction component with safe defaults: normalised paths checked against the target, no absolute paths or symlinks, and limits on total bytes, entries and compression ratio counted while copying. It has to be easier than copying a snippet, so it comes with a starter and docs.
Third, untrusted archives should be extracted in isolated workers with memory, disk and time limits, so a miss cannot take down a customer-facing service. Fourth, static analysis in CI across all repositories, CodeQL's Zip Slip query or a Semgrep rule for entry names used as paths, first as a warning and then blocking.
Fifth, add it to secure coding training and to the design review checklist. And I would report progress with numbers: services fixed, repositories on the component, CI findings trending to zero, and the next pen test coming back clean.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- The Java Language Specification, Java SE 21, Java SE 21 API documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Security found Zip Slip and zip bomb vulnerabilities in four different services that...": https://scrivio-interview-library.netlify.app/java/io-and-nio/3ae936a27c/