Skip to content
Merged
421 changes: 421 additions & 0 deletions docs/research/2026-11-centrs-credentials/README.md

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions docs/research/2026-11-centrs-credentials/probe/agent-shell-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
# Credentials research: run by the agent itself, from its own shell tool in a
# T3 session (not through /container/shell). Reports, for this shell, whether
# each marker is present (zeros included) and the parent chain (process names
# from comm and parent IDs, never command lines, which could hold a value), so
# the result shows which process the environment came through. Prints no values.
for v in LAB_ROUTER LAB_PROBE_ENV CENTRS_CDB_PASSWORD CENTRS_CDB_PASSWORD_FILE; do
if [ -n "${!v+x}" ]; then echo "$v=present"; else echo "$v=absent"; fi
done
pid=$$
while :; do
ppid=$(awk '/^PPid:/{print $2}' "/proc/$pid/status" 2>/dev/null)
echo "pid=$pid ppid=${ppid:-?} comm=$(cat "/proc/$pid/comm" 2>/dev/null)"
[ -z "$ppid" ] || [ "$ppid" -le 1 ] && break
pid=$ppid
done
26 changes: 26 additions & 0 deletions docs/research/2026-11-centrs-credentials/probe/boot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh
# Runs at every container start (the probe app's command). Appends one
# record to /data/boots. Records the secret only as length + sha256, so the
# log shows same/different without the value.
{
echo "=== boot $(date -u +%FT%TZ)"
env | grep '^P_' | sed 's/^\(P_[A-Z_]*SECRET[A-Z_]*=\).*/\1<redacted>/'
if [ -n "$P_SECRET_ENV" ]; then
echo "P_SECRET_ENV len=${#P_SECRET_ENV} sha=$(printf %s "$P_SECRET_ENV" | sha256sum | cut -c1-12)"
fi
ls -ln /run/secrets 2>&1
for f in /run/secrets/*; do
[ -f "$f" ] && echo "$f len=$(wc -c < "$f") sha=$(sha256sum < "$f" | cut -c1-12)"
done
echo "id: $(id)"
ip -4 addr show | grep inet
ip -4 route
GW=$(ip -4 route | awk '/^default/{print $3}')
for t in "$GW" "$P_NET_ROUTER_IP" "$P_ROUTER_IP"; do
[ -z "$t" ] && continue
for p in 22 80 443 8728 8729; do
if nc -z -w 3 "$t" "$p" 2>/dev/null; then echo "tcp $t:$p open"; else echo "tcp $t:$p closed"; fi
done
echo "rest $t admin/empty: $(wget -q -T 5 -O- "http://admin:@$t/rest/system/identity" 2>&1 | head -c 200)"
done
} >> /data/boots 2>&1
20 changes: 20 additions & 0 deletions docs/research/2026-11-centrs-credentials/probe/env-sampler.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
# Credentials research: sample processes for ~330 s (past T3's 300 s provider
# re-probe) and record, once per pid, whether a codex-related process carries
# LAB_PROBE_ENV (provider-instance env) and LAB_ROUTER (T3's own env).
out=/tmp/env-sampler.out; : > "$out"; seen=" "
end=$((SECONDS + 330))
while [ "$SECONDS" -lt "$end" ]; do
for p in /proc/[0-9]*; do
pid=${p#/proc/}
case "$seen" in *" $pid "*) continue ;; esac
cmd=$(tr '\0' ' ' < "$p/cmdline" 2>/dev/null) || continue
case "$cmd" in *codex*) ;; *) continue ;; esac
e=$(tr '\0' '\n' < "$p/environ" 2>/dev/null) || continue
seen="$seen$pid "
# Record the process name (comm), never its command line, which could hold a value.
echo "$(date -u +%T) pid=$pid probe=$(grep -c '^LAB_PROBE_ENV=' <<< "$e") router=$(grep -c '^LAB_ROUTER=' <<< "$e") comm=$(cat "$p/comm" 2>/dev/null)" >> "$out"
done
sleep 0.2
done
echo "finished" >> "$out"
19 changes: 19 additions & 0 deletions docs/research/2026-11-centrs-credentials/probe/host-account.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
# Credentials research: switch the host record in the encrypted CDB from
# admin to the router-made account t3code, whose password is the same
# /run/secrets value. Then read, and try one write the group must refuse.
# The write runs only if the switch worked and the read authenticated as
# t3code (guards added after the 2026-11-25 run, which passed both).
sum() { jq -c '{ok, data: (.data|tostring|.[0:60]), err: .error.code, user: .meta.operation.auth.username,
src: ((.meta.settings // {}) | {username: .username.kind, password: .password.kind})}'; }
h=$(awk '$2=="00000000"{print $3; exit}' /proc/net/route)
GW=$(printf '%d.%d.%d.%d' "0x${h:6:2}" "0x${h:4:2}" "0x${h:2:2}" "0x${h:0:2}")
CENTRS_CDB_PASSWORD=$(cat /run/secrets/routeros_pw)
export CENTRS_CDB_PASSWORD
set_out=$(printf %s "$CENTRS_CDB_PASSWORD" | centrs devices set "$GW" --user t3code --password-stdin --json)
jq -c '{ok, err: .error.code, msg: .error.message}' <<< "$set_out"
jq -e '.ok == true' <<< "$set_out" > /dev/null || { echo "devices set failed; skipping the write test" >&2; exit 1; }
echo "== read as t3code"; read_out=$(centrs retrieve "$GW" /system/identity --json); sum <<< "$read_out"
jq -e '.meta.operation.auth.username == "t3code"' <<< "$read_out" > /dev/null || { echo "host does not authenticate as t3code; skipping the write test" >&2; exit 1; }
echo "== write as t3code (should fail)"
centrs execute "$GW" --yes '/system/identity/set name=changed' --json | sum
35 changes: 35 additions & 0 deletions docs/research/2026-11-centrs-credentials/probe/in-container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
# Credentials research, run inside the app-t3code container as node through
# /container/shell. Prints no secret values: lengths, sources and outcomes only.
# Upload to the container's /tmp (see ../README.md "Reproduce").
sum() { jq -c '{ok, data: (.data|tostring|.[0:60]), err: .error.code,
user: .meta.operation.auth.username, pw: .meta.operation.auth.passwordProvided,
src: ((.meta.settings // {}) | {host: .host.kind, username: .username.kind, password: .password.kind})}'; }

echo "== id: $(id)"
echo "== /run/secrets"; ls -ln /run/secrets
f=/run/secrets/routeros_pw
[ -r "$f" ] && echo "readable by $(id -un), len $(wc -c < "$f")"
echo "== env: LAB_ROUTER=${LAB_ROUTER:-unset}; env lines naming the secret: $(env | grep -ci routeros_pw)"
env | grep '^CENTRS_' | sed 's/=.*/=<set>/'
h=$(awk '$2=="00000000"{print $3; exit}' /proc/net/route)
GW=$(printf '%d.%d.%d.%d' "0x${h:6:2}" "0x${h:4:2}" "0x${h:2:2}" "0x${h:0:2}")
echo "== gateway from /proc/net/route: $GW"

echo "== 1 CENTRS_HOST only"; CENTRS_HOST=$LAB_ROUTER centrs retrieve /system/identity --json | sum
echo "== 2 positional, no creds"; centrs retrieve "$LAB_ROUTER" /system/identity --json | sum
echo "== 3 env admin + empty password"
CENTRS_USERNAME=admin CENTRS_PASSWORD='' centrs retrieve "$LAB_ROUTER" /system/identity --json | sum

K=$(cat "$f")
echo "== 4 encrypted CDB init, key from /run/secrets (via env, not argv)"
CENTRS_CDB_PASSWORD=$K centrs devices init --encrypt --json | jq -c '{ok, err: .error.code, data: (.data | {cdbFile, encrypted, changed})}'
echo "== 5 __default__ = admin, empty password"
CENTRS_CDB_PASSWORD=$K centrs devices add __default__ --user admin --password '' --json | jq -c '{ok, err: .error.code, msg: .error.message}'
echo "== 6 host record"
CENTRS_CDB_PASSWORD=$K centrs devices add "$GW" --group host --json | jq -c '{ok, err: .error.code, msg: .error.message}'
echo "== 7 retrieve host with CDB key"; CENTRS_CDB_PASSWORD=$K centrs retrieve "$GW" /system/identity --json | sum
echo "== 8 retrieve host without CDB key"; centrs retrieve "$GW" /system/identity --json | sum
echo "== 9 list without CDB key"; centrs devices list --json | jq -c '{ok, err: .error.code}'
c=$HOME/.config/tikoci/winbox.cdb
echo "== 10 CDB file"; ls -ln "$c"; echo "plaintext 'admin' occurrences: $(grep -c -a admin "$c")"
24 changes: 24 additions & 0 deletions docs/research/2026-11-centrs-credentials/probe/probe.tikapp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: credprobe
descr: app-t3code credentials/context probe (placeholders, secrets, router reachability)
category: development
services:
probe:
image: alpine:3.20
command: ["sh", "-c", "sh /data/boot.sh 2>/dev/null || echo no-boot-script >> /data/boots; exec sleep 999999999"]
environment:
P_ROUTER_IP: "[routerIP]"
P_NET_ROUTER_IP: "[networkRouterIP]"
P_CONTAINER_IP: "[containerIP]"
P_ACCESS_IP: "[accessIP]"
P_CONTAINER_IF: "[containerInterface]"
P_SECRET_ENV: "[secret:routeros_pw]"
P_LITERAL: plain
secrets:
- routeros_pw
volumes:
- probe-data:/data
restart: unless-stopped
secrets:
routeros_pw:
volumes:
probe-data: {}
13 changes: 13 additions & 0 deletions docs/research/2026-11-centrs-credentials/probe/provider-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# Credentials research: which running processes carry LAB_PROBE_ENV (set as a
# Codex provider-instance environment variable in T3's settings.json) and
# LAB_ROUTER (set in the container env, so inherited from the T3 server).
# Prints PIDs, process names (comm) and marker counts, never command lines.
for p in /proc/[0-9]*; do
e=$(tr '\0' '\n' < "$p/environ" 2>/dev/null) || continue
a=$(grep -c '^LAB_PROBE_ENV=' <<< "$e"); b=$(grep -c '^LAB_ROUTER=' <<< "$e")
[ "$a$b" = "00" ] && continue
echo "pid $(basename "$p") probe=$a router=$b comm=$(cat "$p/comm" 2>/dev/null)"
done
# Names and flags only, never an environment value.
echo "settings providerInstances: $(jq -c '(.providerInstances // {}) | map_values({driver, environment: [(.environment // [])[] | {name, sensitive}]})' /data/.t3/userdata/settings.json 2>/dev/null)"
11 changes: 11 additions & 0 deletions docs/research/2026-11-centrs-credentials/probe/set-provider-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
# Credentials research: give the Codex provider instance one plain (not
# sensitive) environment variable through T3's settings.json.
s=/data/.t3/userdata/settings.json
[ -f "$s" ] || echo '{}' > "$s"
set -e
jq '.providerInstances.codex = ((.providerInstances.codex // {driver: "codex"})
+ {environment: [{name: "LAB_PROBE_ENV", value: "from-settings", sensitive: false}]})' "$s" > "$s.new"
mv "$s.new" "$s"
chmod 600 "$s"
jq -c .providerInstances "$s"
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Lab copy of app/t3code.tikapp.yaml for the credentials research: adds an
# app-level secret (as a file only, no env placeholder) and one address
# placeholder. Core tools only, Codex only, to keep the pull and install small.
# Pinned to the measured build (a -app.<N> tag never moves); the 2026-11-25
# run pulled :0.1, which was 0.1.11-app.221 then.
name: t3code
descr: T3 Code server (credentials lab)
category: development
url-path: /
services:
t3code:
image: ghcr.io/tikoci/app-t3code:0.1.11-app.221
ports:
- "3773:3773:web:tcp"
environment:
HOME: /data
T3CODE_HOME: /data/.t3
T3CODE_HOST: 0.0.0.0
T3CODE_PORT: "3773"
T3CODE_TELEMETRY_ENABLED: "false"
T3APP_TOOL_GROUPS: "none"
T3APP_PROVIDERS: "codex"
T3APP_SKILLS: "tikoci/routeros-skills"
LAB_ROUTER: "[networkRouterIP]"
secrets:
- routeros_pw
volumes:
- t3code-data:/data
restart: unless-stopped
secrets:
routeros_pw:
volumes:
t3code-data: {}