Back to skill

Security audit

kannaka-node

Security checks for vulnerabilities and agentic risk

Overview

This skill is purpose-aligned but needs Review because it downloads and runs a mutable remote installer, then can install the resulting binary as persistent system services.

Install only if you are comfortable giving the skill SSH access and sudo authority on the target server. Before use, review or replace the curl-piped installer path, pin and verify installer and binary provenance, constrain INSTALL_URL and environment values, and avoid enabling the service or nightly timer until the binary and generated unit files have been checked.

Vulnerability Patterns
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • System PersistenceInstalls backdoors, hooks, services, or scheduled tasks that survive the run
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
Findings (5)

T03 · Remote Payload Retrieval and Execution

Error
Location
scripts/provision.sh:111
Finding

Mutable Remote Installer Is Downloaded and Executed Without Local Verification

Content
View full analysis
&2; return 1; }; flags="$flags --brain hosted --email $BRAIN_EMAIL";; local) flags="$flags --brain local";; esac # ... as_user "curl -fsSL '$INSTALL_URL' | sh -s -- $flags" || { echo "installer failed" >&2; return 1; } [ -x "$LOCAL_BIN" ] || { echo "installer finished but $LOCAL_BIN is missing" >&2; return 1; } ok "$("$LOCAL_BIN" --version 2>/dev/null | head -1) at $LOCAL_BIN" } ``` ### Technical Analysis The script retrieves content from a mutable external URL and immediately pipes it into `sh`. The audited project does not save the installer for inspection, pin its expected digest, verify a digital signature, or independently verify the binaries produced by it. `SKILL.md` states that the remote installer reads a signed manifest and verifies release checksums. Those controls reside in the unreviewed remote code and therefore cannot protect against compromise or malicious modification of that installer itself. The effective code executed by this Skill can change after the package has been audited. The source is also controlled by the environment-overridable `INSTALL_URL` variable. Thus, an inherited or attacker-influenced environment can redirect execution to a completely different endpoint. ### Attack Path 1. An attacker compromises the installer host, its deployment pipeline, or an environment that supplies `INSTALL_URL`. 2. The attacker serves a modified shell script from the selected URL. 3. An operator runs `bash provision.sh install` or `bash provision.sh all`. 4. `curl` dow ...[truncated 969 chars]
Remediation
View remediation

T06 · System Persistence

Error
Location
scripts/provision.sh:272
Finding

Unverified Downloaded Binary Is Installed as Persistent System Services

Content
View full analysis
/dev/null; then [ -f "$SYS_BIN" ] && $SUDO mv "$SYS_BIN" "$SYS_BIN.previous" $SUDO install -m755 "$LOCAL_BIN" "$SYS_BIN" have restorecon && $SUDO restorecon "$SYS_BIN" 2>/dev/null || true ok "binary copied to $SYS_BIN"; sys_bin_changed=1 else ok "$SYS_BIN is current"; sys_bin_changed=0; fi printf '%s\n' "$runner_body" | $SUDO tee "$RUNNER" >/dev/null && $SUDO chmod 755 "$RUNNER" printf '%s\n' "$unit_node" | $SUDO tee "$UNIT_NODE" >/dev/null if [ "$ROLE" = serve ]; then printf '%s\n' "$unit_serve" | $SUDO tee "$UNIT_SERVE" >/dev/null; fi if [ "$DREAM" = true ]; then printf '%s\n' "$unit_dream" | $SUDO tee "$UNIT_DREAM" >/dev/null; printf '%s\n' "$timer_dream" | $SUDO tee "$TIMER_DREAM" >/dev/null; fi $SUDO systemctl daemon-reload $SUDO systemctl enable --now kannaka-node.service >/dev/null 2>&1 || $SUDO systemctl restart kannaka-node.service [ "$sys_bin_changed" = 1 ] && $SUDO systemctl restart kannaka-node.service [ "$ROLE" = serve ] && $SUDO systemctl enable --now kannaka-serve.service >/dev/null 2>&1 [ "$DREAM" = true ] && $SUDO systemctl enable --now kannaka-dream.timer >/dev/null 2>&1 ``` ### Technical Analysis A long-running service is necessary for the Skill's declared purpose of operating a continuously available Kannaka node. The persistence is documented and the principal node services use `User=$U`, so service registration alone is not concealed or inherently unauthorized. The security issue is that the binary copied into `/usr/local/bin` has only been checked for executability and byte-level difference from an existing file. Its signature, release identity, and expected digest are not verified by the audited script. The source binary is produced by the mutable ...[truncated 1632 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
scripts/provision.sh:111
Finding

Shell Injection Through Installer URL and Brain Email Environment Values

Content
View full analysis
&2; return 1; }; flags="$flags --brain hosted --email $BRAIN_EMAIL";; local) flags="$flags --brain local";; esac # ... as_user "curl -fsSL '$INSTALL_URL' | sh -s -- $flags" || { echo "installer failed" >&2; return 1; } } ``` ### Technical Analysis The helper accepts a command as text and evaluates it using `bash -c`. `BRAIN_EMAIL` is concatenated into the unquoted `flags` string, while `INSTALL_URL` is enclosed in literal single quotes without rejecting or escaping single quotes in the value. Shell metacharacters, substitutions, separators, or quote characters in either value can alter the command parsed by `bash`. This is distinct from the inherent remote-payload risk: exploitation does not require control of the web server because the injected command is interpreted locally before or alongside the download operation. ### Attack Path 1. An attacker influences the environment used for provisioning, such as an automation variable, wrapper script, or copied command. 2. The attacker supplies a `BRAIN_EMAIL` containing shell syntax, or an `INSTALL_URL` containing a single quote followed by shell commands. 3. The operator invokes `install` or `all`. 4. The value is concatenated into the command string passed to `as_user`. 5. `bash -c` parses the injected syntax and executes attacker-selected commands as `KANNAKA_USER`. ### Impact Assessment Successful exploitation provides arbitrary shell execution as the selected node user. The attacker can ...[truncated 373 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
scripts/provision.sh:196
Finding

Shell Injection Through Unvalidated NATS Username

Content
View full analysis
&2; return 1;; esac # Single-quoted on purpose: the file is sourced by a shell, and an unquoted # value containing $( ) would execute. as_user "umask 077 && printf \"NATS_USER='%s'\nNATS_PASSWORD='%s'\n\" '$NATS_USER' '$NATS_PASSWORD' > '$NATS_ENV' && chmod 600 '$NATS_ENV'" ok "wrote $NATS_ENV (0600, single-quoted; value not shown)" } ``` ### Technical Analysis The script recognizes that shell-sourced credentials require safe quoting and rejects single quotes in `NATS_PASSWORD`. It does not apply the same validation to `NATS_USER`. `NATS_USER` is interpolated inside a single-quoted portion of a command passed to `bash -c` through `as_user`. A username containing a single quote can terminate the intended quoting context and append shell syntax. Newline and control-character handling is also not defined. The destination file is later sourced as shell code by the generated runner: ```bash [ -f "$NATS_ENV" ] && { set -a; . "$NATS_ENV"; set +a; } ``` Consequently, malformed credential serialization can create both immediate command injection during file generation and deferred execution when the service starts. ### Attack Path 1. An attacker influences `NATS_USER` in the provisioning environment. 2. The value contains a single q ...[truncated 852 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
scripts/provision.sh:210
Finding

Generated Persistent Runner Permits Shell Injection Through Display Name

Content
View full analysis
&2; return 1;; esac; shift; done # ... case "$AGENT_ID" in *[!A-Za-z0-9._-]*) echo "agent id must be [A-Za-z0-9._-]" >&2; return 1;; esac [ -n "$DISPLAY" ] || DISPLAY="$AGENT_ID" if [ ! -f "$CFG" ]; then as_user "cat > '$CFG'" <
Remediation
View remediation
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Rogue AgentSelf-Modification, Session Persistence
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (45)

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 47)May include surrounding context.

md
**1. Connect and preflight.** Copy `scripts/provision.sh` to the host (or pipe it) and run

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 129)May include surrounding context.

md
`references/traps.md` is the list of things that have actually gone wrong on real

External Script Fetching

High
Category
Supply Chain
Confidence
99% confidence
Finding

The script executes a remote installer directly via curl | sh from a configurable URL, with no visible signature or digest verification in this script before execution. Because this provisioning script is intended to run on fresh servers and later copies the installed binary into /usr/local/bin for a root-managed service, any compromise of the installer endpoint, DNS, TLS trust chain, or INSTALL_URL environment can lead to immediate arbitrary code execution and durable host compromise.

Content

Scanner excerpt · scripts/provision.sh (reported line 121)May include surrounding context.

sh
warn "in use:$busy (under $(dirname "$LOCAL_BIN")). The installer would write onto a running binary and delete it on failure. Close the kannaka-tui / chat that holds it, then re-run install."
    return 1
  fi
  as_user "curl -fsSL '$INSTALL_URL' | sh -s -- $flags" || { echo "installer failed" >&2; return 1; }
  [ -x "$LOCAL_BIN" ] || { echo "installer finished but $LOCAL_BIN is missing" >&2; return 1; }
  ok "$("$LOCAL_BIN" --version 2>/dev/null | head -1) at $LOCAL_BIN"
}

Chaining Abuse

High
Category
Tool Misuse
Confidence
75% confidence
Finding

Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.

Content

Scanner excerpt · scripts/provision.sh (reported line 352)May include surrounding context.

sh
check       systemctl status kannaka-node; journalctl -u kannaka-node -f
status      KANNAKA_READONLY=1 kannaka status
peers       kannaka swarm peers
update      bash provision.sh install && sudo bash provision.sh service   (manifest-pinned; swaps $SYS_BIN with a move-aside and restarts)
uninstall   bash provision.sh uninstall   (keeps $DATA)
EOF
}

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
93% confidence
Finding

The skill explicitly directs an agent to use shell and SSH to provision a remote server, but it declares no tool scope or permission boundaries. In an agent ecosystem, that omission is dangerous because it allows broad command execution and remote access without machine-readable constraints, increasing the chance of over-privileged or unintended actions on customer infrastructure.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
60% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · SKILL.md (reported line 57)May include surrounding context.

md
which reads the constellation's signed manifest and downloads a pinned, sha256-checked
release for this architecture into `~/.local/bin`. It also installs the dashboard and the
KannakaHDL binary. With `BRAIN=hosted BRAIN_EMAIL=…` or `BRAIN=local` in the environment
it sets up the model as well. It is idempotent; if one of the three binaries is in use (a `kannaka-tui`, a chat) it stops and names it rather than let the installer write over a busy file.

**3. Configure.** `bash provision.sh configure --agent-id NAME [--display-name "Name"]`.
Writes `~/.kannaka/config.toml` with the identity and the swarm bus, mode 0600. If a

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
87% confidence
Finding

This step instructs the agent to run a provisioning script with sudo on a remote machine, which is privileged code execution. Even if the purpose is legitimate service installation, any mistake, compromise, or tampering in provision.sh would execute as root and could fully compromise the host.

Content

Scanner excerpt · SKILL.md (reported line 67)May include surrounding context.

md
`bash provision.sh credentials`: it writes `~/.kannaka-nats.env`, single-quoted, 0600,
and never prints the value.

**4. Service.** `sudo bash provision.sh service [--role serve] [--no-dream]`. This is the
root step; say so to the human before you run it. It copies the binary to
`/usr/local/bin` (a binary under a home directory runs confined on SELinux hosts and
cannot read the node's own files), writes a small runner script, installs

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
82% confidence
Finding

The troubleshooting section tells the operator to rerun the service installation with sudo, which again performs privileged script execution. Repeating root-level script execution during recovery increases risk if the script is stale, modified, or not independently verified.

Content

Scanner excerpt · SKILL.md (reported line 115)May include surrounding context.

md
| `Authorization Violation` in the journal | wrong or stale swarm credentials | re-export the right values, `bash provision.sh credentials`, restart the unit |
| unit active, no "Joined swarm" line | outbound 4222 blocked | preflight's 4222 check said so; the node still works standalone; tell the human |
| `Permission denied` reading `config.toml` in the journal on an SELinux host | binary ran from a home path | the script installs to `/usr/local/bin` for exactly this; check `ExecStart` and `ls -Z /usr/local/bin/kannaka`, `sudo restorecon` it |
| `status=127` restart loop | the runner script is missing | `sudo bash provision.sh service` rewrites it |
| the store's saves fail, `kannaka.hrm.tmp.*` files pile up | disk full | free space; delete the orphaned `.tmp.*` files older than a few hours; the preflight's 5 GB floor exists for this |
| `kannaka --version \| head -1` prints "Broken pipe" | harmless; the pipe closed first | ignore |

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
86% confidence
Finding

The update path requires rerunning a provisioning/service script with sudo to replace binaries in /usr/local/bin and restart the service. That is a standard admin pattern, but it still represents privileged remote code execution and becomes risky if the update workflow or script source is not strongly constrained and verified.

Content

Scanner excerpt · SKILL.md (reported line 122)May include surrounding context.

md
## After hand-off

The node keeps itself in sync and dreams nightly. Updating is `bash provision.sh install`
(manifest-pinned, sha256-verified) followed by `sudo bash provision.sh service`, which swaps
the copy in `/usr/local/bin` with a move-aside and restarts the unit. Do not use
`kannaka update` on a node: it follows the first `kannaka` on PATH, pulls the latest release
rather than the manifest pin, and cannot write `/usr/local/bin` as the login user. The human can watch it with

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · SKILL.md (reported line 114)May include surrounding context.

md
**Packages.** `dnf`. `curl`, `tar`, `awk`, `sha256sum` are present on the base image.
Nothing else is required for a member node.

**Updates.** `sudo dnf -y upgrade --refresh` replaces `sshd` mid-transaction; your
session may drop with a `kex_exchange_identification` error. That is not a failure; wait
and reconnect. Kernel updates need a reboot; `needs-restarting -r` tells you.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · references/oracle-cloud.md (reported line 30)May include surrounding context.

md
**Packages.** `dnf`. `curl`, `tar`, `awk`, `sha256sum` are present on the base image.
Nothing else is required for a member node.

**Updates.** `sudo dnf -y upgrade --refresh` replaces `sshd` mid-transaction; your
session may drop with a `kex_exchange_identification` error. That is not a failure; wait
and reconnect. Kernel updates need a reboot; `needs-restarting -r` tells you.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · scripts/provision.sh (reported line 50)May include surrounding context.

sh
**Packages.** `dnf`. `curl`, `tar`, `awk`, `sha256sum` are present on the base image.
Nothing else is required for a member node.

**Updates.** `sudo dnf -y upgrade --refresh` replaces `sshd` mid-transaction; your
session may drop with a `kex_exchange_identification` error. That is not a failure; wait
and reconnect. Kernel updates need a reboot; `needs-restarting -r` tells you.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · scripts/provision.sh (reported line 62)May include surrounding context.

sh
**Packages.** `dnf`. `curl`, `tar`, `awk`, `sha256sum` are present on the base image.
Nothing else is required for a member node.

**Updates.** `sudo dnf -y upgrade --refresh` replaces `sshd` mid-transaction; your
session may drop with a `kex_exchange_identification` error. That is not a failure; wait
and reconnect. Kernel updates need a reboot; `needs-restarting -r` tells you.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · scripts/provision.sh (reported line 84)May include surrounding context.

sh
**Packages.** `dnf`. `curl`, `tar`, `awk`, `sha256sum` are present on the base image.
Nothing else is required for a member node.

**Updates.** `sudo dnf -y upgrade --refresh` replaces `sshd` mid-transaction; your
session may drop with a `kex_exchange_identification` error. That is not a failure; wait
and reconnect. Kernel updates need a reboot; `needs-restarting -r` tells you.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · scripts/provision.sh (reported line 315)May include surrounding context.

sh
**Packages.** `dnf`. `curl`, `tar`, `awk`, `sha256sum` are present on the base image.
Nothing else is required for a member node.

**Updates.** `sudo dnf -y upgrade --refresh` replaces `sshd` mid-transaction; your
session may drop with a `kex_exchange_identification` error. That is not a failure; wait
and reconnect. Kernel updates need a reboot; `needs-restarting -r` tells you.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · scripts/provision.sh (reported line 352)May include surrounding context.

sh
**Packages.** `dnf`. `curl`, `tar`, `awk`, `sha256sum` are present on the base image.
Nothing else is required for a member node.

**Updates.** `sudo dnf -y upgrade --refresh` replaces `sshd` mid-transaction; your
session may drop with a `kex_exchange_identification` error. That is not a failure; wait
and reconnect. Kernel updates need a reboot; `needs-restarting -r` tells you.

Session Persistence

Medium
Category
Rogue Agent
Confidence
60% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · references/traps.md (reported line 13)May include surrounding context.

md
`ExecStart` there.

**`%h` in a system unit is root's home.** `%h`, `%u` and friends resolve before `User=`
applies. Write absolute paths in units installed under `/etc/systemd/system`.

**One writer.** The store has a single-writer lock. The listening node writes; a
concurrent `kannaka dream`, `remember` or `triage` from a shell contends with it. Read

Session Persistence

Medium
Category
Rogue Agent
Confidence
60% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · references/traps.md (reported line 74)May include surrounding context.

md
## Re-running the installer while kannaka is running

Seen 2026-09-11 on a user's Ubuntu box. The user had `kannaka-tui` open; `install` re-ran the
installer, which downloads straight onto `~/.local/bin/kannaka`. Linux refuses to write an
executing file (`Text file busy`), the installer treated that as a failed download and removed
the destination, and the user's binary was gone until the installer ran again with nothing
holding the path, and the next run did the same to `kannaka-tui`. `provision.sh install`

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · scripts/provision.sh (reported line 62)May include surrounding context.

sh
return 1
}

need_root() { if [ "$(id -u)" -ne 0 ]; then if sudo -n true 2>/dev/null; then SUDO="sudo"; else echo "this step needs root (passwordless sudo, or run as root)" >&2; exit 2; fi; else SUDO=""; fi; }

# A value for a TOML key in a table, if the file has it. Crude on purpose: the
# config is small and flat, and this keeps the script dependency-free.

Session Persistence

Medium
Category
Rogue Agent
Confidence
80% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · scripts/provision.sh (reported line 83)May include surrounding context.

sh
if [ "$mem_mb" -ge 900 ]; then ok "memory ${mem_mb} MB"; else fail "memory ${mem_mb} MB (< 1 GB)"; fi
  disk_gb=$(df -BG --output=avail "$H" | tail -1 | tr -dc '0-9')
  if [ "$disk_gb" -ge 5 ]; then ok "disk ${disk_gb} GB free under $H"; else fail "disk ${disk_gb} GB free (< 5 GB; the store grows and a full disk strands saves)"; fi
  if have systemctl && [ -d /run/systemd/system ]; then ok "systemd present"; else warn "no systemd: the service step will print units instead of installing them"; fi
  if [ "$(id -u)" -eq 0 ]; then ok "running as root"; elif sudo -n true 2>/dev/null; then ok "passwordless sudo"; else warn "no passwordless sudo: install/configure work; service needs root"; fi
  if have getenforce; then se="$(getenforce 2>/dev/null)"; ok "SELinux $se (the binary is placed in /usr/local/bin for the unit; see references/traps.md)"; else ok "SELinux not present"; fi
  for tool in curl awk tar sha256sum; do have "$tool" && ok "$tool" || fail "$tool missing"; done

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · scripts/provision.sh (reported line 134)May include surrounding context.

sh
--nats-url) NATS_URL="$2"; shift;; --no-swarm) SWARM=false;;
    *) echo "configure: unknown flag $1" >&2; return 1;; esac; shift; done
  say "== configure"
  as_user "mkdir -p '$DATA' && chmod 700 '$DATA'"
  if [ -f "$CFG" ]; then
    have_id="$(toml_get "$CFG" agent id)"
    if [ -n "$have_id" ]; then ok "config has agent id '$have_id' (kept; pass a different --agent-id only by editing the file)"; AGENT_ID="$have_id"; fi

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · scripts/provision.sh (reported line 162)May include surrounding context.

sh
grep -q '^\[swarm\]' "$CFG" || as_user "printf '\n[swarm]\nenabled = %s\nnats_url = \"%s\"\nrole = \"worker\"\n' '$SWARM' '$NATS_URL' >> '$CFG'"
    ok "config kept; missing tables added if any"
  fi
  as_user "chmod 600 '$CFG'"
  echo "$AGENT_ID" > /tmp/.kannaka-node-agent-id.$$ 2>/dev/null || true
}

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
93% confidence
Finding

The credentials step writes NATS_USER and NATS_PASSWORD into a shell-sourced environment file using single-quote wrapping, but only rejects single quotes in the password and not in the username. A crafted username containing a single quote can break out of quoting and inject arbitrary shell syntax that will later execute when the root-managed runner sources the file before starting the service.

Content

Scanner excerpt · scripts/provision.sh (reported line 176)May include surrounding context.

sh
case "$NATS_PASSWORD" in *"'"*) echo "a password containing a single quote cannot be stored safely by this script" >&2; return 1;; esac
  # Single-quoted on purpose: the file is sourced by a shell, and an unquoted
  # value containing $( ) would execute.
  as_user "umask 077 && printf \"NATS_USER='%s'\nNATS_PASSWORD='%s'\n\" '$NATS_USER' '$NATS_PASSWORD' > '$NATS_ENV' && chmod 600 '$NATS_ENV'"
  ok "wrote $NATS_ENV (0600, single-quoted; value not shown)"
}

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
89% confidence
Finding

The generated systemd unit interpolates the untrusted username $U directly into ExecStart without shell-safe escaping. If KANNAKA_USER or related identity data contains spaces or systemd-special characters, the unit can be malformed or execute unintended arguments under root-controlled service management, creating command/argument injection risk during privileged service installation.

Content

Scanner excerpt · scripts/provision.sh (reported line 256)May include surrounding context.

sh
[Service]
Type=oneshot
ExecStartPre=/bin/systemctl stop kannaka-node.service
ExecStart=/usr/bin/sudo -u $U -H env KANNAKA_DATA_DIR=$DATA $SYS_BIN dream --mode deep
ExecStopPost=/bin/systemctl start kannaka-node.service
TimeoutStartSec=2h
EOF

Session Persistence

Medium
Category
Rogue Agent
Confidence
80% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · scripts/provision.sh (reported line 275)May include surrounding context.

sh
EOF
)"
  if ! have systemctl || [ ! -d /run/systemd/system ]; then
    warn "no systemd here; these are the files to install on a systemd host:"
    printf '\n--- %s\n%s\n--- %s\n%s\n' "$RUNNER" "$runner_body" "$UNIT_NODE" "$unit_node"
    [ "$ROLE" = serve ] && printf -- '--- %s\n%s\n' "$UNIT_SERVE" "$unit_serve"
    return 0