Lecture Notes
This lecture will present an overview over OS specific injections and exploration with LOLBins.
Download here or here with generated lecture notes.
Notes were generated with the help of AI and reviewed by staff. If you find an issue, please report it.
Practical tasks
Each of the fourteen applications hides one face of the same disease: input that reaches an interpreter as instructions instead of data. The goal is not only to collect the flags — it is to be able to explain, for every app, what you tried, what you saw, and why it worked.
1. Before you start
1.1 What you are looking for
Injection is an item of the OWASP Top 10 (A05:2025 — Injection) — happens when an application hands user input to something that interprets it: a shell, a template engine, an XML parser, a URL fetcher, a deserializer, a program-name resolver. The input is not the data the consumer processes; it is part of the code the consumer executes. The shell then runs your text as part of its command; the engine evaluates your expression; the parser opens the file your document points at.
In this suite the interpreter is almost never a SQL database. It is the operating system itself (or the runtime sitting on it) — which is why the payoff, and the risk, is so large: in most of these apps a successful injection is a command running as the service user.
One more fact about this suite, useful from the start: no app here contains the flag. In every one of the fourteen, the secret lives in a file the application never reads — the only code that ever reads it is the code you made run. If your approach never makes the service execute anything, it will not find the flag.
All apps contain exactly one deliberate flaw of this kind. Everything else in the apps works as a normal application should.
1.2 Your targets
| App | Address | Port | Value | Consumer (verify by recon) | Lang |
|---|---|---|---|---|---|
| LibraryNet | http://inj1.chal.deti:8040 |
8040 | 100 | shell — command split | Python |
| ShelfTag | http://inj2.chal.deti:8041 |
8041 | 100 | shell — behind a character filter | Python |
| OpsBoard | http://inj3.chal.deti:8042 |
8042 | 150 | template engine (Jinja2) | Python |
| Catalogo | http://inj4.chal.deti:8043 |
8043 | 150 | XML parser | Java |
| NightPack | http://inj5.chal.deti:8044 |
8044 | 150 | shell — fixed program, your argument | Go |
| CardCraft | http://inj6.chal.deti:8045 |
8045 | 200 | template engine (EJS) | Node.js |
| DeskOne | http://inj7.chal.deti:8046 |
8046 | 150 | shell — via a log line, output elsewhere | Python |
| StockEye | http://inj8.chal.deti:8047 |
8047 | 200 | shell — behind a character filter | PHP |
| PicLink | http://inj9.chal.deti:8048 |
8048 | 200 | URL fetcher (the app fetches for you) | PHP |
| ToolDesk | http://inj10.chal.deti:8049 |
8049 | 250 | program-name resolution (the search path) | Python |
| LogWarden | http://inj11.chal.deti:8050 |
8050 | 200 | shell — a stored value, executed later | Python |
| SessionVault | http://inj12.chal.deti:8051 |
8051 | 250 | deserializer (Python pickle) | Python |
| FaaSDeck | http://inj13.chal.deti:8052 |
8052 | 250 | shell — a “serverless” platform, two doors | Python |
| GateKeeper | http://inj14.chal.deti:8053 |
8053 | 200 | shell — behind a gate (WAF) | Python |
1.3 Rules of engagement
- Only these targets, and only from your own lab VM. Do not touch any other lab service, student VM, or CTFd instance.
- Extraction is the mission — and it goes through execution. The flags live in files
the apps never show you; to get one, you must make the service run something that
reads the file. Read what you need to get the flag and stop. Do not write, modify,
or delete anything on a target — no
rm, no overwriting, no “what else could I do” beyond a read. In a real engagement, a read-only proof is the line where a lawful test stays a finding; crossing it makes it an incident. Noting that a write is possible is part of the report; exercising it is not. - No denial of service. These are small single containers; flooding them hurts the class.
- The flag rotates after every accepted submission (one rolling flag is shared per app and is re-rolled when anyone solves). If your submission is rejected after you extracted a flag, someone else solved while you were reading — re-run your extraction.
- A flag-shaped string that CTFd refuses is a decoy, not a lab bug. At least one app in this suite deliberately hides a fake flag where “read the configuration” looks like the solution. Note which one, and why it is there, in your report.
- The PoC bench runs on your own machine only. The lab targets are for the fourteen challenges; the bench is for your fourteen PoCs. Never point a bench PoC at a lab target, and never point a lab payload anywhere but the app it belongs to.
1.4 Tools
A browser plus curl is enough for most of this. You will want curl’s raw-string mode and
web advise the use of Python’s requests/urllib for the challenges where the payload needs a byte the
browser’s form will not give you — a real newline, a percent sign that must survive a
decode, a parameter that appears twice.
2. The shape of the problem
2.1 The common root cause
In every app, somewhere, code looks like this (schematically):
subprocess.run(f"ping -c 1 {user_input}", shell=True)
The input is part of the instructions the consumer receives, not the data it processes. Your first job in each app is to find the input that reaches a consumer — and to name the consumer, because the consumer decides everything else. Your second job is to find out what comes back to you when the consumer does more than you asked: sometimes the answer is in the response; sometimes it is in a file the app serves later; sometimes nothing comes back to you at all, and you must reason about where the app puts what it just did.
2.2 The execution model decides the technique
The single most important idea in this lab (the sibling of “the feedback channel decides the technique” in the SQLi guide):
The technique you can use is determined by the execution model: which consumer the input reaches, in which context, and — if a filter stands in the way — what view of the bytes the filter has.
Trace the input’s path and watch closely. Classify each app against this table before you read its “you should see” — the classification is the observation.
| What the input becomes | Family | You will meet it in |
|---|---|---|
| part of a shell command string, no filter | OS command injection — command splitting | LibraryNet, NightPack |
| part of a shell command string, behind a character filter | OSi — filter evasion (find what the filter misses) | ShelfTag, DeskOne, StockEye |
| a stored value that a different code path executes later | second-order injection | LogWarden |
| a template the engine renders | server-side template injection (SSTI) | OpsBoard, CardCraft |
| an XML document the parser consumes | XXE | Catalogo |
| a URL the application fetches on your behalf | SSRF | PicLink |
| a serialized object the app reconstructs | deserialization | SessionVault |
| a name that must resolve to a program | command override (search-path shadowing) | ToolDesk |
| a “function” or “command args” on a platform that claims isolation | (serverless) command injection | FaaSDeck |
| a command inspected by a gate before the runner | WAF evasion | GateKeeper |
2.3 Three facts that will bite you
- A character filter is a list of what to remove. The question to ask is never “does it block
;?” but “which character that splits, quotes, or expands is missing?” You will meet the answer three different times. - A separator needs a command in front of it. A payload that starts with
; …is a shell syntax error, not an injection. Start it with a harmless real command. You will feel this wall exactly once; remember it. - The interesting output is not always in the response. Some apps run your code and show you the result; others run it and put the result in a file, a log, or a page you have not opened yet. Before you declare an injection dead, ask where the app writes what it just did.
And one fact about the suite as a whole: the apps echo a lot — the command they ran, the file they touched, the value they parsed. Read the echo. This is not common on real world applicatiosn and is used here for training.
2.4 Generic patterns, by family (adapt, don’t paste)
These are shapes not solutions for any one app.
Swap in a harmless marker first (an echo or a distinctive string) to prove control before
you reach for the flag. None of these include a path; finding what the service user can
read is your job (start with a listing of the filesystem, not a guess at a filename).
OS command injection — splitting (no filter). The input lands inside a shell string.
Any shell metacharacter that ends the first command and starts a new one works —
;, |, &&, ` / $() for substitution instead of sequencing. Remember: a
payload cannot start with the separator, because the shell still needs something valid
before it.
<legit-arg>; id
<legit-arg> && whoami
<legit-arg> | ls -la /
OS command injection — filter evasion. First enumerate the filter’s blind spots, not its blocked list: try each separator above one at a time and see which survive. If every separator is gone, look for what still expands — a shell variable, a wildcard, a quoting trick — before concluding the filter is complete. A filter is a blacklist; its coverage is never larger than what someone thought to list.
SSTI (template engines). Confirm first with pure arithmetic — a template evaluates it, static text does not:
{{7*7}} (Jinja2-family)
<%= 7*7 %> (EJS-family)
Once the engine evaluates expressions, the question becomes what objects the template’s namespace exposes back to a process/filesystem primitive — explore from there rather than pasting a known RCE gadget blind; the gadget differs by engine and sandboxing.
XXE. An external entity declared in the DOCTYPE, referenced in the body, pointed at a local path:
<?xml version="1.0"?>
<!DOCTYPE foo [ <!ENTITY x SYSTEM "file:///etc/hostname"> ]>
<foo>&x;</foo>
Swap the path for something low-risk first (/etc/hostname) to confirm the parser
resolves external entities before you go looking for anything sensitive.
SSRF. The app fetches a URL you supply. Start by pointing it at yourself (if you can
run a listener) or at a loopback/metadata-style address and see what comes back — the
interesting question is which schemes and hosts it will follow, not just whether it
fetches http://.
Deserialization. Don’t hand-craft bytes if the language’s own pickle/serializer
library can build them for you locally.
Build the smallest object whose reconstruction has a side effect (a __reduce__ that
calls a function), serialize it, and submit the bytes/base64 the app expects. Prove the
side effect with something harmless before chasing the flag.
Search-path shadowing. If the app resolves a name to a program rather than taking a full path, ask what determines where it looks, and whether anything you control (a working directory, an env var, an upload) lets you place a same-named file earlier in that search.
WAF / gate evasion. Same rule as filter evasion: enumerate what the gate doesn’t inspect — a different encoding, a different separator, a request shape the gate’s parser sees differently than the runner that executes it afterward.
3. The applications
For each app: what you can do with it, what to try first (hint), what you should observe, and the conclusion you should be able to write down. Work them in order — each one teaches a skill the next one reuses.
3.1 LibraryNet — inj1.chal.deti:8040 (100)
A library-network dashboard. The one feature: “ping an OPAC node” — you name the node, the service pings it, and the ping’s output is shown to you in a box.
Try first. Ping the default node and a node that does not exist — note the shape of
both outputs. Then look at the form: you type a name, and the service has to turn it
into a ping command. Ask what stands between your field and that command, and which
single character would let your field end the ping and start something else. Prove the
shell runs your second command with something harmless you recognize in the output (your
own text). Then ask the question this whole lab answers: what can this service user
read? Start with a listing.
You should see.
- Your marker text comes back in the “ping” output — the field reached a shell, and the
shell ran more than
ping. - A listing of the filesystem shows a directory no legitimate feature of this app mentions. Inside it: the flag.
- Possibly, a flag-shaped string inside the app’s own configuration that CTFd refuses: the decoy. It is there to punish “read the config” — the real secret is read by your shell, not by the app.
Conclude. OS command injection by command splitting: the node name is concatenated into a shell string, and a metacharacter ends the first command and starts yours. The app itself never touches the secret — your command does, with the service user’s privileges. This is the base case; every other shell app in this suite is a variation on it.
For your report: the splitter you used (there are several — which did you try first,
and why), the listing that revealed the flag’s directory, the decoy, and the one-line
fix: run ping without a shell (an argument list) and validate the host.
3.2 ShelfTag — inj2.chal.deti:8041 (100)
A store-label service. You give a SKU and a line of text; the service queues the label for the back-room printer. Before it does, it “sanitizes” the text.
Try first. Learn the sanitizer by fighting it: send each shell metacharacter you can think of, one at a time, and watch what survives into the label (each removed character breaks the command in a slightly different way — the errors are your map). The filter is a short list; the shell’s grammar is a longer one. Which character that also ends a command does the filter not strip? Note that the text field is a single-line box in the browser — but a form value is just bytes, and your tools can send characters a keyboard cannot.
You need to provide some data, a metacharacter and then the command you want to execute: x<META>command
The relevant snippet is:
# The "security" the developer added: a blacklist.
BLOCKED = re.compile(r"[;|&$\`]")
TIP: You can encode binary characters (such as \n) directly in hex. As an example \n becomes %0A.
You should see.
- The stripped characters are gone from the output (the label is mangled, but the
command still runs); the one unstripped character
%0Ais not. - With that character in the value, the first line of your text is consumed by the label writer, and the second line runs as its own command — and because the label’s content is what the page shows you, whatever your second line prints is what you read back.
Conclude.
Filter evasion: an incomplete blacklist.
The developer listed the
characters everyone thinks about and did not list the one that also ends a command (\n). A
filter is a list of removals, not a list of permissions — and a list of removals is only
as strong as its first hole.
For your report: each character you probed and how the filter treated it, the missing character, and why “just add it to the blacklist” is still the wrong fix (what is the fix?).
3.3 OpsBoard — inj3.chal.deti:8042 (150)
A store-operations dashboard. The report header is “a nice little template feature”: the
default header contains {{ report_date }}, which the page replaces with today’s date.
Try first.
Use the default header — the date appears (that is the feature with {report_date}). Now
submit an expression the app never defined: some arithmetic in the same marks. Two
outcomes are possible: the page shows your marks literally (it is a string
substitution — safe), or it shows the result (the engine executed your text — that is
the issue).
Which one did you see? If it executed arithmetic {{1+1}}, it will execute anything
the engine’s own objects can reach: from one of the engine’s built-in objects to a module
that can run commands is a short chain — the engine ships with default objects, and those
objects carry references to their modules.
You should see.
- Your arithmetic comes back evaluated (
{{1+1}}). The header is code the engine runs. - With the right chain, the report preview carries the output of a command you made the
server run. Interesting examples would be
{{ cycler.__init__.__globals__}}and from theglobalsyou can use modules such asoswith...__globals__.os.methodname. From this you can spin topopen("cmd").read(). But this is not the only solution as you can add further code.
Conclude. Server-side template injection: the input is the template — the program of a template engine. This is the server-side cousin of XSS: same shape (marks in the page), opposite side (executed on the server, with the service’s privileges, before the page ever reaches a browser). The arithmetic test is the discriminator; write it in your report.
For your report: the recon test and its result, the chain you used (or found) from engine internals to a command, and the fix: user text is rendered as data (a fixed template with a data slot), never as a template — and if the product genuinely needs user templates, a sandboxed engine with an allowlist of what the template may touch.
3.4 Catalogo — inj4.chal.deti:8043 (150)
A library-catalogue import. You post a small XML record; the service parses it and shows you the record’s text (and keeps the last few in a “recent imports” list).
Try first. Import a normal record — the text is reflected. Now remember what XML is not: not just data. A document can also carry instructions for the parser — declarations that name things. What XML construct lets you declare a name whose value comes from outside the document? Try it against a file you are certain exists on any Unix machine (a small system file — not the secret yet). The app’s error text is verbatim from the parser: a wrong path and a right path fail differently, and that difference is your probe.
You should see.
- Use
<record><id>12</id><title>1</title></record> - You can declare entities in the doctype
<!DOCTYPE r [<!ENTITY xxe SYSTEM "file:///fname">]> &xxewill contain the content that you want.
Conclude.
XXE (CWE-611): the XML data contains instructions (an entity declaration) that the parser obeys, because the parser was configured with defaults — “it worked on my machine.” Same root cause as a previous app in a different interpreter: the consumer (here the parser) does not separate the document’s data from its directives.
For your report: the declaration you wrote, the error text that told you a path existed, and the fix: a parser that will not process the declaration at all (or at least will not resolve what it declares) — name the exact hardening in your own words.
3.5 NightPack — inj5.chal.deti:8044 (150)
A store backup tool. You name a directory; the tool packs it into tonight’s archive. The tool is a fixed program (an archiver) — but the argument slot is yours, and the tool is invoked through a shell string, the way an ops one-liner is.
Try first. Run the default backup name — the archiver’s output is reflected to the webpage. Now look at the command shape: a fixed program, a fixed archive name, your directory, a fixed redirect.
Ask: is the directory slot really just a directory? (another app taught you how a string becomes two commands with a META — nothing about that changed just because the first program’s name is fixed.) The shell does not know which part of the string is “the program” or the “other prgoram”
You should see.
- The legitimate backup runs first, then your second command can run, and the page shows both outputs in one box — the archive and your text, side by side.
- This should be simple as you can pivot from the previous apps.
Conclude.
Argument exploitation: a fixed program whose argument is
attacker-controlled, reached through a shell string. The mistake is not that the archiver
is dangerous — it is that the code hands the whole string to a shell (sh -c) instead of
handing the program an argument list. In an argument list, your ; would be a boring
character inside a boring path.
For your report: the payload shape, why the fixed program name does not save you, and the fix (argument list, no shell — plus a directory allowlist, because “the user may name any directory” is a second, quieter flaw).
3.6 CardCraft — inj6.chal.deti:8045 (200)
A bookstore gift-card service with a “bring your own design” feature: the card is a small HTML template with slots for recipient and message, filled server-side by a real template engine.
Try first. Print a card with the default design — the slots fill correctly. Now notice who controls what: the slots are for data, but the template itself is typed by you and rendered by an engine that executes templates. Make your template do arithmetic.
If it evaluates, you found the same issue as a previous app — with a different engine, a different runtime. The template executes with the language’s global objects in scope, but not with the module loader. Find the global that knows about this process, and ask it for the built-in module that can run commands. (When your expression is wrong, the engine’s error page is chatty — use it.)
You should see.
- The engine is
EJSand differs from the previous. - Your arithmetic renders in the card preview
<=% 1+2 %>. - With the right expression, the card carries the output of a command the server ran for
you. Start with
<=% process %>from which you can usegetBuiltinModule('child_process').execSync(COMMAND).
Conclude.
SSTI again: here the user supplies the whole template, not a value that is reflected into one. A template is code by definition — “let the customer design their card” and “let the customer run code on the server” are the same sentence; only the second one sounds alarming.
For your report: how you reached a command-running function without a module loader, the engine and runtime you identified (and how), and the fix (never render a user-supplied template; if “custom design” is a product requirement, a true sandbox with an allowlisted expression language — and say why “escaping the output” is not a fix at all).
3.7 DeskOne — inj7.chal.deti:8046 (150)
A library service desk. You open a ticket (requester + priority); every ticket is written to a desk log “the way the ops script always did it”, and there is a public page showing the last lines of that log.
Try first. Open a ticket and read the log page — your name is there, word for word. Note what the ticket response does not contain (nothing interesting).
The desk’s sanitizer strips a few characters. Then the question: which shell feature takes a command, runs it, and pastes its output into the string in its place — using only characters that survive that particular filter? Build it into your requester name.
And now the twist: your command’s output will not appear in the ticket response. It appears where the log line goes.
You should see.
- The ticket page looks exactly as innocent as before.
- Try several META characters and see their result:
% ; || && $ ` ( ). - Check how the shell executes commands inline such as with
$(...)or`...`. - The log page carries your command’s output, embedded in the log line — because the shell ran the command while the app was writing the log.
Conclude.
Command substitution: the same root cause, a quieter door. The log line is built through a shell, so the log line is a command; the substitution construct runs inside the string before the string ever becomes a log entry.
The lesson generalizes: any line of code that builds a shell string from untrusted input is an injection point — even one that “only writes a log”.
For your report: the surviving substitution form (and the characters the filter did and did not strip), where the output landed and why not the response, and the fix (log with a logging library or file API — no shell anywhere near a log line).
3.8 StockEye — inj8.chal.deti:8047 (200)
A store-inventory audit. You name a path; the service lists it and then shows its contents. The input passes a “careful” filter first.
Try first. Audit the default file — list, then content. Now audit a directory you can guess exists: you will get the listing but the content step will fail (you cannot cat a directory).
So learn the filter by probing, and ask the question this app is built around: the command shape is fixed (ls … then cat …) and you control only the argument — which character does the filter not strip that the shell will expand to a list of files? One character. You have used it in a terminal since day one.
Also, you cannot use /flag/flag as the filter will block it.
You should see.
- The probe listing reveals a directory with exactly one file in it — and you already know what that file is.
- Explicit paths are forbidden
- However the glob character
*is not restricted. - Try using it to get the flag at the usual location, without accessing the full path directly.
Conclude. Parameter expansion (globbing) past an incomplete blacklist: the shell expands the character, not the app, so no app-level filter that forgets it can stop it. Pair the two lessons: argument exploitation plus filter evasion — the argument slot can become several arguments.
For your report: the probe that named the file, the character and who expands it, and the fix (resolve the path and confine it to the tree the audit is allowed to see — or drop the shell and read the file in-process, in which case the character means nothing).
3.9 PicLink — inj9.chal.deti:8048 (200)
A store image proxy: paste a URL, and the service fetches it for you and shows you the picture. It is the “CDN link checker” — the application performs the request, whatever you point it at.
Try first. Preview an address you can reach (the app’s own front page is a fine first test — you will get HTML “as an image”). The bytes come back exactly as fetched.
Now ask what “URL” means to the fetch function: addresses have schemes, and the ones for the network are not the only kind. Which scheme makes the fetcher read from the local filesystem instead of the network? Prove it on a system file first. Then the address of the suite’s secret is a guessing game you have already won — it is the path every shell challenge in this suite led you to; you are only pointing the fetcher at it.
You should see.
- A non-network scheme fetches a local file, and the response serves its bytes with an image content type — the page is a text file, and your browser will happily tell you so, by showing an error.
- The secret’s path, fetched, comes back as a “picture”.
Conclude. SSRF (CWE-918), in its purest small form: the application fetches what you name, with no check on where the address points. The interesting detail for your report: the application never “reads the flag” — its fetch function does, on your behalf, as the service user. The same split as the first the app’s code is innocent; the interpreter (here the fetch layer) is what obeys your input.
For your report: the recon fetch that proved the scheme, the final request, and the fix in two layers (allowlist the scheme to http/https; then resolve the target and deny local, loopback, and private addresses — and say which layer stops which attack).
3.10 ToolDesk — inj10.chal.deti:8049 (250)
A diagnostics dashboard with a plugin system: you can run the stock diagnostics tool, or upload a small script as a “plugin”. Read the page carefully — it tells you, in plain words, how the runner searches for tools: the plugin path is searched before the stock tools.
Try first. Run the stock tool — note its name and its output. Upload a plugin with a brand-new name and run it — it runs. Now ask the three questions this app lives on:
- (1) when the runner is told to run a tool by name, and two files with that name exist on the search path, which one wins?
- (2) Which name should your uploaded script therefore have?
- (3) The upload form validates the plugin name very strictly — what does it say nothing about?
You should see.
- Your uploaded script — whose content the form never inspected
- You can override existing tool names, try it.
Conclude.
Command override / search-path shadowing: the attacker does not type the command at all — they control which binary a name resolves to. Name validation and content are two different things: the filter on the name is correct and irrelevant. This is the same root cause wearing its most bureaucratic face: the dangerous “command” is not in any input field; it is in a file the service will happily execute.
For your report: the shadowed name and why it wins, the distinction between the validated thing and the unvalidated thing, and the fix (run stock tools by absolute path and never put a user-writable directory ahead of the stock ones on the search path; uploaded “plugins” are untrusted code — review/sign them, or do not run them as the service at all).
3.11 LogWarden — inj11.chal.deti:8050 (200)
A log-shipper control panel. Two features: save the directory the shipper reads from, and run the shipper now. The save feature validates its input.
Try first. Save the default directory and run the shipper — it lists the directory and tails its log. Now read the save-time validation by probe: what exactly must the value satisfy? (“An absolute path” — that is all.)
Ask the question that splits this challenge from the first app: the value is checked here, stored here, and used there — in a different feature, later, by code that trusts the config file. In which of the two contexts is the string data, and in which is it code? Which context did the validation design for?
You should see.
- The store accepts a value and the checker is happy to call a path, and echoes it back proudly.
- The shipper’s output carries the output of a command the “path” contained — the value was data when it was stored and code when it was shipped.
- The shippper trusted a local value because it was internal, not provided by an user.
- If the path has more into it, it may break the command and execute code as previously discovered.
Conclude.
Second-order injection: the taint and the execution are separated by storage and time. A filter at the input point sees a path, not a payload — because the payload only exists in the execute context, which the filter was never looking at. This is the shape of many real incidents: the developer who wrote the save never thought about a shell; the developer who wrote the shipper trusted the config.
For your report: why one request was not enough (the store/ship sequence), exactly what the “absolute path” check does and does not prove, and the fix (allowlist the directory against the set of directories the shipper may actually use; pass it to the shell as an argument, never interpolated — or do the listing in-process).
3.12 SessionVault — inj12.chal.deti:8051 (250)
A session-restore service. You paste a saved “workspace” — a base64 blob — and the service restores it and shows you a preview of what it contains.
Try first. Work backwards from the format: base64 of what? The service is a Python service, and the standard-library word for “a Python object saved to bytes” is the one you need — serialize a harmless object (a small dictionary) on your own desktop, encode it, and restore it here: the preview should show you its name.
class R:
def __init__(self):
pass
# base64 blob to send
blob = base64.b64encode(pickle.dumps(R())).decode()
Now the model question, the one that decides this challenge: when the service restores an object, is it
parsing data or executing a plan? This method is named __reduce__ and is described here
A serialized object can carry instructions for its reconstruction, specifically a hook that says “to rebuild me, call this callable with these arguments”, and the service will run that call with its own privileges.
What does the preview do with an object that can read? (Observe the app’s behaviour: what kinds of restored objects does it treat specially?)
You should see.
- A harmless object restores fine (the pipeline works, the format is confirmed).
- An object whose reconstruction plan opens the suite’s secret file restores to… that file — and the preview, which helpfully reads file-like objects, hands you the content.
Conclude.
Deserialization: reconstruction is execution. There is no metacharacter, no shell, no filter to evade — the serialized bytes themselves are the instruction set, and the app runs it because “restore the user’s workspace” and “execute the user’s code” are the same operation for a general-purpose serializer.
For your report: the object you built and the hook it used, why the preview was the reflection point, the language companions (and their safe loaders), and the fix (never deserialize untrusted bytes; if restore is a product feature, carry a schema — a data format with no code path — and validate it).
3.13 FaaSDeck — inj13.chal.deti:8052 (250)
A function platform. Three features: deploy a function (name + body), invoke it (with an input), and exec into a cluster pod (pick a pod, give it arguments). The platform’s front page says, in so many words: each function runs in its own isolated environment.
Try first. Deploy a trivial function and invoke it — the body runs, the input is piped to it. Now look at the two execution doors with the question “what is this string, to the runner?”: (1) the body of a deployed function — what does the platform do with it, really? (2) the exec API — the pod list is an allowlist; ask what it checks and what it does not check. And test the isolation claim: does a function run in a world different from the rest of the service? (You do not need to read the platform’s source — you have a shell, if you look at the right door.)
You should see.
- Either door gives you a command running as the service user — the function body is a pipeline the platform runs for you, and the exec arguments are joined into a shell string where the pod allowlist has already waved you through.
- The “isolated environment” is the same user, the same filesystem, the same flag.
Conclude. (Serverless) command injection — the isolation slide, made concrete: “serverless” is a billing model, not a security boundary, and an exec API is a remote shell by construction; the allowlist is at the wrong layer (it checks which container, not what it may run). The platform’s claim and the kernel’s facts disagree; the kernel wins.
For your report: which door you used (and why the function body, not the input, is the injection point), what the pod allowlist does and does not control, what real isolation would require (a different user, a filesystem without the secret, no shell in the exec path), and the fix per door.
3.14 GateKeeper — inj14.chal.deti:8053 (200)
An admin-diagnostics API: one parameter, cmd, and the service runs it. In front of the
service sits a WAF that inspects every command “to be safe” — and the service,
“defensively”, looks at the value a second time.
Try first. Run the default diagnostic (ls of the app directory) — it works. Now try
a payload with a splitter, single-parameter, plainly encoded: you should get a 403
from the WAF. Keep that response — it is your control, the proof that the gate works
on the naive path. (You will need to have hit the issue in the third app by now: a bare ; … is a
syntax error, so the payload must start with a real command.)
The app’s response shows you, in a code box, which value it actually ran — use it to learn how the app reads the parameter. Then ask the two questions the WAF’s design invites:
- (a) between the wire and the app, how many times is the value percent-decoded — and do the WAF and the app decode the same number of times?
- (b) if the same parameter appears twice in one request, which occurrence does each side read?
You should see.
- The naive payload is blocked (
ls;cat...); - The WAF behaves may behave differently based on the command, and command position (1st, vs 2nd)
- Also, Filters are complex to implement.
- Select the most permissable position and the adequate META encode.
Conclude. WAF evasion — and the deeper lesson the challenge is really teaching: a blacklist applied to one view of the request fails the moment the attacker and the defender disagree about which bytes count (encoding depth, parameter multiplicity). The app’s real contract is “run one of a known set of diagnostics” — the correct control is an allowlist of that set, with the command passed as an argument list, no shell, and one canonical decode that WAF and app share. A WAF can still sit in front; it is depth, not the control.
For your report: the 403 control, both doors (distinguish them — they are different bugs), and the fix written as a change to the app’s contract, not as “better WAF rules”.
4. What the apps prove together
When you have finished, you should be able to write these without looking anything up:
- One root cause, many consumers. Every app hands user input to an interpreter — a shell, a template engine, an XML parser, a fetch layer, a deserializer, a name resolver — without separating data from instructions. What differs is the consumer, the context, and the filter (if any); the disease is the same.
- The filter is the weakest layer in the building. Every app in this suite that “sanitizes” is defeated by one missing character (a newline, a glob, a substitution) or one missing view of the bytes (a second decode, a second parameter). A blacklist of removals is only as strong as its first hole; an allowlist of what is meant is the control that does not have that failure mode.
- The same string is data in one context and code in another. The logdir is a path when stored and a command when shipped; the plugin name is validated and the plugin content is code; the gate reads the first parameter and the app runs the last. Context — not content — is where the meaning lives, and the fix must live in the same place.
- Claims are recon, not facts. “Sanitized”, “standard XML”, “isolated environment”, “behind a WAF” — each of these four phrases appears in this suite, and each of them is wrong in the way that matters. Your report should record, per app, the claim you were offered and the observation that refuted it.
- The fix is structural, and it is mostly one sentence: data is never code — argument lists instead of shell strings, safe parsing instead of trusting the document (no doctypes, safe loaders, allowlisted schemes), allowlists instead of blocklists, one canonical view of the request. Everything else — least privilege, no secrets where the service user reads, read-only filesystems, no user-writable directories on the search path — is depth, not the fix.
- The impact is the service user’s world. In most of these apps you did not “break a page” — you obtained a command running as the service, able to read anything that user can read and write anything that user can write. The flag is the smallest proof. In a real engagement you stop at “this is possible, here is the read-only proof, here is the scope of what the service user can touch” — and that is exactly what your report does.
5. Build it, break it, fix it — the PoC bench
The challenges proved the problems exist. This section makes you prove them yourself, on your own machine, with the smallest code that can still fail: for each family you get a few lines of deliberately vulnerable code, you write the PoC that demonstrates the behaviour, you apply the mitigation, and you re-run the PoC to show it now does nothing. The bench runs locally only — it has no secret, and none of its endpoints may ever be pointed at the lab.
5.1 The bench
One file, standard library only (no framework to install — plain python3 is enough).
Save it as bench.py on your VM and run python3 bench.py; it listens on
127.0.0.1:8099 (localhost only — keep it that way).
#!/usr/bin/env python3
"""bench.py — a deliberately vulnerable teaching bench. LOCAL USE ONLY.
One file, standard library only. Each endpoint is the smallest possible
version of one injection family from the lab suite. The bench has no
secret: your PoC demonstrates *behaviour* (a marker string, a file of
your own), never a flag, and never a lab target.
Run: python3 bench.py -> http://127.0.0.1:8099
Fams: /cmd command splitting, substitution, globbing (+ your filter)
/tpl server-side template injection
/xml XXE (toy parser: expands DTD-declared entities)
/fetch SSRF (fetches whatever address you name)
/restore deserialization (unpickles what you post)
/plugins + /run command override (search-path shadowing)
/save + /ship second-order (stored value, executed later)
/run2 WAF evasion (gate decodes once / reads first param;
app decodes twice / reads last param)
"""
import base64
import os
import pickle
import re
import subprocess
import urllib.parse
import urllib.request
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
from urllib.parse import parse_qs
PLUGIN_DIR = "/tmp/bench-plugins"
CONFIG = {"logdir": "/tmp/bench-logs"}
def sh(cmd: str) -> str:
p = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=10)
return (p.stdout + p.stderr).strip() or "(no output)"
class Handler(BaseHTTPRequestHandler):
def _reply(self, body: str, code: int = 200):
b = body.encode("utf-8", "replace")
self.send_response(code)
self.send_header("Content-Type", "text/plain; charset=utf-8")
self.send_header("Content-Length", str(len(b)))
self.end_headers()
self.wfile.write(b)
def _form(self) -> dict:
n = int(self.headers.get("Content-Length") or 0)
return parse_qs(self.rfile.read(n).decode("utf-8", "replace"))
def do_GET(self):
path, _, query = self.path.partition("?")
if path == "/":
self._reply("bench: POST /cmd /tpl /xml /fetch /restore /plugins /save /run\n"
" GET /ship /run2?cmd=...\n")
elif path == "/ship":
d = CONFIG["logdir"] # stored ... executed later
self._reply(f"ship (logdir={d})\n{sh(f'ls -la {d}')}\n")
elif path == "/run2":
vals = parse_qs(query).get("cmd", [])
if vals and re.search(r"[;|&$`]", vals[0]): # the gate: first value
self._reply("403 — gate: request blocked\n", 403)
return
v = urllib.parse.unquote(vals[-1]) if vals else "" # the app: last value
self._reply(f"run {v!r}\n{sh(v)}\n")
else:
self._reply("not found\n", 404)
def do_POST(self):
f = self._form()
def one(k: str, d: str = "") -> str:
return f.get(k, [d])[0]
if self.path == "/cmd":
v = one("v")
# (filter-evasion family: insert your "sanitizer" here, before sh())
self._reply(f"cmd {v!r}\n{sh('ls -la ' + v)}\n")
elif self.path == "/tpl":
v = one("v")
m = re.search(r"\{\{(.*?)\}\}", v, re.S)
out = str(eval(m.group(1))) if m else v # "the engine"
self._reply(f"rendered: {out}\n")
elif self.path == "/xml":
v = one("v")
for name, uri in re.findall(r'<!ENTITY\s+(\w+)\s+SYSTEM\s+"([^"]+)"', v):
with urllib.request.urlopen(uri) as fh: # no scheme check
v = v.replace("&" + name + ";",
fh.read().decode("utf-8", "replace"))
t = re.search(r"<title>(.*?)</title>", v, re.S)
self._reply("imported: " + (t.group(1).strip() if t else "(no title)") + "\n")
elif self.path == "/fetch":
url = one("url")
try:
with urllib.request.urlopen(url, timeout=5) as r:
data = r.read(2000)
self._reply("fetched " + url + ":\n" +
data.decode("utf-8", "replace") + "\n")
except Exception as e:
self._reply(f"fetch failed: {type(e).__name__}: {e}\n", 502)
elif self.path == "/restore":
try:
obj = pickle.loads(base64.b64decode(one("blob"), validate=True))
if hasattr(obj, "read"): # "it may be a file-like blob"
self._reply("restored: " + str(obj.read()) + "\n")
else:
self._reply("restored: " + repr(obj) + "\n")
except Exception as e:
self._reply(f"restore failed: {type(e).__name__}: {e}\n", 400)
elif self.path == "/plugins":
name, script = one("name"), one("script")
if not re.fullmatch(r"[A-Za-z0-9._-]+", name):
self._reply("bad plugin name\n", 400)
return
os.makedirs(PLUGIN_DIR, exist_ok=True)
p = os.path.join(PLUGIN_DIR, name)
with open(p, "w") as fh:
fh.write(script)
os.chmod(p, 0o755)
self._reply(f"plugin {name} installed\n")
elif self.path == "/run":
tool = one("tool")
self._reply(f"{tool}\n{sh(f'PATH={PLUGIN_DIR}:$PATH {tool}')}\n")
elif self.path == "/save":
logdir = one("logdir").strip()
if not logdir.startswith("/"):
self._reply("logdir must be an absolute path\n", 400)
return
CONFIG["logdir"] = logdir
self._reply(f"config saved: {logdir}\n")
else:
self._reply("not found\n", 404)
def log_message(self, *args):
pass
if __name__ == "__main__":
os.makedirs("/tmp/bench-logs", exist_ok=True)
open("/tmp/bench-logs/app.log", "a").close()
ThreadingHTTPServer(("127.0.0.1", 8099), Handler).serve_forever()
Read it top to bottom before touching it: each endpoint is the smallest possible version
of one of the apps’ mistakes. /cmd is the base case; the others are its
variants — a filter in front of it, a template engine, a parser, a fetcher, a
deserializer, a name resolver, a stored value, a gate.
Two honest notes about the bench:
/tplis not a real template engine — it is two lines that do what every real engine does: evaluate the expression in your text. On the live challenges it is the real thing (Jinja2 and EJS); on the bench the point is the evaluation, not the dialect./xmlis a labelled toy: Python’s default XML parser does not resolve external entities, so the endpoint performs the entity expansion itself — which is exactly what an unhardened parser does for you (as Catalogo’s parser does). The lesson — a document’s declarations are instructions the consumer obeys — is unchanged.
5.2 The PoC protocol
For each family below, do the same five steps, in order, and keep the evidence:
- Baseline. Fire the endpoint with a normal value. Save the output.
- PoC. Write the smallest request that makes the bench do something you did not ask
it to — print a marker string you chose (e.g.
POC-MARKER-123), or read a file on your own machine (your own file, your own directory — the bench is local, so “the flag” of this exercise is a file you made yourself). Save the request (the exactcurlline) and the output. - Claim. One sentence: which consumer, which character or construct, why it worked.
- Fix. Apply the mitigation for that family (edit a copy of the bench — keep the vulnerable original).
- Verify. Re-run the exact same PoC request against the fixed bench. Save the output. It must show the request being treated as data (or refused) — and the baseline must still work.
A PoC that only works with a flag, or only works on a lab target, does not demonstrate the problem — the problem is the behaviour, and behaviour can be shown with a marker.
5.3 The families
For each row: what your PoC must show, what the fix must be, and your acceptance test.
(Fixes 1, 2, 3, 4 all converge on the same one-line change to /cmd — that is the point:
the argument list kills the whole shell family at once.)
| # | Family (bench endpoint) | Your PoC must show | Apply this fix | Verify (same request, fixed bench) |
|---|---|---|---|---|
| 1 | command splitting — /cmd |
a second command runs: your marker appears although it is not a path ls was given |
no shell: an argument list (["ls", "-la", v]) + validate the value |
the marker arrives as a literal, boring argument (ls: cannot access) |
| 2 | filter evasion — /cmd + your sanitizer |
add a “sanitizer” that strips ; and &; your PoC finds the missing character (what else ends a command?) and splits anyway |
the real fix is row 1; if a filter must exist, it rejects (not removes) values containing newlines — and your report says why removal is the wrong shape | the PoC is refused or inert |
| 3 | command substitution — /cmd |
a command’s output appears in the echoed line (the hostname, the content of your file) — no splitter character at all | argument list, no shell — substitution is a shell service | the substitution text is echoed literally |
| 4 | parameter expansion — /cmd |
a * in your value makes ls list files you never named |
confine the value to an allowed tree (resolve it, check the prefix) or row 1 | the * is literal; nothing extra is listed |
| 5 | SSTI — /tpl |
{{ 7 * 7 }} renders as 49, then an expression runs a command and returns its output |
user text is data: no evaluation of user text — a fixed template with a data slot (or a sandboxed engine with an allowlist) | your marks render literally |
| 6 | XXE — /xml |
a document whose declaration points at a file on your own machine comes back containing that file | do not process the declaration at all (reject the document, or a parser configured to never resolve external names) | the document is refused or the declaration ignored — no file content |
| 7 | SSRF — /fetch |
a non-network scheme serves a local file; and the bench’s own address (http://127.0.0.1:8099/) is fetchable by the bench |
allowlist the scheme (http/https) and resolve the target: deny file/loopback/private | the request is refused before any fetch |
| 8 | deserialization — /restore |
a serialized object whose reconstruction opens your file is “restored” and read by the preview | never deserialize untrusted bytes: a data format with no code path (JSON) + schema validation | the request is refused, or parsed as inert data |
| 9 | command override — /plugins + /run |
an uploaded script whose name matches a stock tool (shadow date — it exists on every machine; its normal output is your baseline) runs your marker instead |
run stock tools by absolute path; never search a user-writable directory first; treat uploads as untrusted code | the stock tool’s own output comes back |
| 10 | second-order — /save + /ship |
a stored “path” that is happy to the save-time check executes a command at ship time | allowlist the value against the directories the shipper may use; pass it as an argument, never interpolated | the ship lists nothing it should not; the value is data |
| 11 | WAF evasion — /run2 |
first the 403 (your control), then either door: an encoding the gate and the runner disagree on, or two values of the same parameter | allowlist the command set + argument list + one canonical decode for gate and app + reject duplicate parameters | the PoC is refused (and the naive 403 is still a 403) |
5.4 Your deliverable
A folder, e.g. injection-poc/, with one subfolder per family: the vulnerable and fixed
bench code (or the diff), the PoC request verbatim, the baseline output, the PoC output,
and the verify output — plus a three-line note per family: root cause / fix / why the
fix works.
Done means: for every family, the same request (a) works on the vulnerable bench, (b) does not work on the fixed one, and (c) can be explained in your three lines. If a family’s “verify” still shows the behaviour, the fix is not the fix — that is the exercise.
6. Your personal lab report (OWASP PTES)
The OWASP Penetration Testing Execution Standard (PTES) describes a penetration test as a sequence of phases. Use those seven phases as the skeleton of a short report on this lab.
Framing: this report is for you — an exercise, not a delivery. Nobody grades its format. Write it as if it were a real engagement write-up you would be proud to show: concrete, evidence-backed, and honest about what you did not manage. The bar is: a person who was not in the lab should be able to read it and reproduce every step.
Phase 0 — Pre-engagement interactions
- Scope: the fourteen targets, addresses, values (your target table).
- Rules of engagement you followed, and any questions you had to resolve.
- Tooling: what you used (browser, curl, your scripts), and why.
Phase 1 — Intelligence gathering
For each app, what you learned before exploiting:
- Endpoints and parameters (where did you find them — forms, URLs, source view?).
- Which inputs are reflected, echoed, or used silently — and where the interesting output lands (response, log page, later run).
- Consumer identification — and the exact observation that told you (which one of the ten from the target table, and the evidence).
- Filter discovery: for the filtered apps, the exact list of what the filter does and does not do — your probes, one per character.
- Data inventory: what can the service user see? (The listing that found the flag’s directory is your first real map.)
Phase 2 — Threat modeling
For each app:
- Which inputs reach which consumer, and what did you assume before you proved it?
- What data in that world is sensitive (not just the flag)?
- If injection succeeds, what is at stake — confidentiality, integrity, availability?
- Trust boundaries: who/what is trusted (the shipper trusting the config, the runner trusting the plugin path, the app trusting the gate’s view of the request)?
Phase 3 — Vulnerability analysis
For each app, one detection entry:
- The test you ran (payload + request).
- The evidence (response snippet or screenshot) — what exactly changed.
- The classification: which of the ten families from the target table, and why not the others.
- Your confidence, and what would have lowered it.
Phase 4 — Exploitation
For each app:
- The full chain from detection to flag (requests, in order).
- What was hardest, and how you got past it (a missing character, a second request, a second decode, a hook you had to build).
Phase 5 — Post-exploitation
For each app, now that you have the service user’s world:
- What else is reachable (other files, other directories) — and what a real attacker would do with it?
- What could be changed (the label file, the config, the log, the plugin directory, the “function store”)?
- What you deliberately did not do, and why. (This is the professional line — make it explicit in the report.)
Phase 6 — Reporting
- A findings table: one row per app — finding, severity, evidence, root cause, impact, remediation.
- A short overall picture: the common root cause, the one-sentence fix that covers the shell family, the per-family fixes, and the depth measures.
- Reflection (this is the part that is really for you):
- Which PTES phase took the most time, and was that what you expected?
- Which family surprised you most? Which filter character did you try last?
- What would you do differently on a second pass?
Appendices (suggested): the payloads you used, verbatim; your PoC bench folder; the 403 control from GateKeeper; the decoy and where it hid.
Self-check — “done” means you can answer, for every one of the fourteen apps: which input, which consumer, which family, which payload, what else was reachable, and the one-line fix — plus, for the filtered apps, which character or view the filter missed. If any app cannot answer all of that, that is your next experiment.
7. References
- OWASP Top 10 — A03:2021 Injection and the per-family pages: Command Injection, Server-Side Template Injection, XXE, SSRF, Insecure Deserialization, HTTP Parameter Pollution.
- OWASP PTES (v2.0) — the report model.