Commit 4795285
messages send + message-to: Layer 3 force-file mode (body-verify defense) (#51)
Mike body-verify directive 2026-05-11 — close the caller-side shell-
expansion bug class on Cue Message outbound. Design Dock workspace:
cue-message-silent-corruption-substrate-design-2026-05-11.
Empirical bug class: BODY="...$(echo X)..." assignment command-
substitutes at variable-assignment time, BEFORE the CLI receives the
arg. Server accepts the (mutated) POST with HTTP 200; recipient sees
corrupted content. Send-helper shell-safety (json.dumps) does NOT
protect against this — the mutation is upstream.
Changes:
cueapi/cli.py — new _acquire_message_body() helper applied to both
messages_send + message_to commands. Body comes from exactly ONE of:
--message-file <path> RECOMMENDED for content with metachars;
zero shell interpolation; reads body
from the given path byte-identical.
--body-stdin read body from stdin (shell-pipe
ergonomics: `echo X | cueapi messages
send --body-stdin --from ... --to ...`).
--body <inline> inline; auto-rejected when content
contains $(...), `...`, or ${VAR}.
Override via --allow-inline-metachars
for legitimate literal-metachar content.
Rejection error gives 3 actionable mitigations. Multiple sources
provided also rejected (exactly one required).
tests/test_cli.py — 9 new tests pin the invariants:
- Reject inline $(...) / backticks / ${VAR}
- Accept inline when metachar-free
- Accept inline with --allow-inline-metachars override
- Accept --message-file (byte-identical incl. metachars)
- Accept --body-stdin (byte-identical)
- Reject multiple body sources
- message-to parity (same Layer 3 guard)
All 219 tests pass (45 existing messages tests + 9 new + 165 others).
Existing API contract preserved: `--from` and `--to` still required;
`--body` still works for metachar-free content (the common interactive
ad-hoc case). New options are additive. The only breaking change is:
inline `--body` with $(...)/backticks/${VAR} now exit-1 with actionable
error instead of silently sending mutated content. That's the intended
Layer 3 behavior.
CHANGELOG entry under [Unreleased].
Phase 3 of body-verify defense-in-depth. Layer 2 (auto-verify via
X-CueAPI-Verify-Echo) ships after Layer 1 substrate header lands
(cueapi-primary's lane, ~1-3d). Layer 4 docs joint with cue-pm.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 2bd30a2 commit 4795285
3 files changed
Lines changed: 324 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| |||
1873 | 1875 | | |
1874 | 1876 | | |
1875 | 1877 | | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
| 1895 | + | |
| 1896 | + | |
| 1897 | + | |
| 1898 | + | |
| 1899 | + | |
| 1900 | + | |
| 1901 | + | |
| 1902 | + | |
| 1903 | + | |
| 1904 | + | |
| 1905 | + | |
| 1906 | + | |
| 1907 | + | |
| 1908 | + | |
| 1909 | + | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
| 1924 | + | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
| 1934 | + | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + | |
| 1949 | + | |
| 1950 | + | |
| 1951 | + | |
1876 | 1952 | | |
1877 | 1953 | | |
1878 | 1954 | | |
| |||
1894 | 1970 | | |
1895 | 1971 | | |
1896 | 1972 | | |
1897 | | - | |
| 1973 | + | |
| 1974 | + | |
| 1975 | + | |
| 1976 | + | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
| 1981 | + | |
| 1982 | + | |
| 1983 | + | |
| 1984 | + | |
| 1985 | + | |
| 1986 | + | |
| 1987 | + | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
| 2000 | + | |
| 2001 | + | |
| 2002 | + | |
| 2003 | + | |
| 2004 | + | |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + | |
| 2015 | + | |
| 2016 | + | |
| 2017 | + | |
| 2018 | + | |
1898 | 2019 | | |
1899 | 2020 | | |
1900 | 2021 | | |
| |||
1979 | 2100 | | |
1980 | 2101 | | |
1981 | 2102 | | |
1982 | | - | |
| 2103 | + | |
| 2104 | + | |
| 2105 | + | |
| 2106 | + | |
1983 | 2107 | | |
1984 | 2108 | | |
1985 | 2109 | | |
| |||
1992 | 2116 | | |
1993 | 2117 | | |
1994 | 2118 | | |
1995 | | - | |
| 2119 | + | |
| 2120 | + | |
| 2121 | + | |
| 2122 | + | |
1996 | 2123 | | |
1997 | 2124 | | |
1998 | 2125 | | |
| |||
2248 | 2375 | | |
2249 | 2376 | | |
2250 | 2377 | | |
2251 | | - | |
| 2378 | + | |
| 2379 | + | |
| 2380 | + | |
| 2381 | + | |
| 2382 | + | |
| 2383 | + | |
| 2384 | + | |
| 2385 | + | |
| 2386 | + | |
| 2387 | + | |
| 2388 | + | |
| 2389 | + | |
| 2390 | + | |
| 2391 | + | |
| 2392 | + | |
| 2393 | + | |
| 2394 | + | |
| 2395 | + | |
| 2396 | + | |
| 2397 | + | |
| 2398 | + | |
| 2399 | + | |
| 2400 | + | |
| 2401 | + | |
| 2402 | + | |
| 2403 | + | |
| 2404 | + | |
| 2405 | + | |
| 2406 | + | |
| 2407 | + | |
| 2408 | + | |
2252 | 2409 | | |
2253 | 2410 | | |
2254 | 2411 | | |
| |||
2330 | 2487 | | |
2331 | 2488 | | |
2332 | 2489 | | |
2333 | | - | |
| 2490 | + | |
| 2491 | + | |
| 2492 | + | |
| 2493 | + | |
2334 | 2494 | | |
2335 | 2495 | | |
2336 | 2496 | | |
| |||
2348 | 2508 | | |
2349 | 2509 | | |
2350 | 2510 | | |
2351 | | - | |
| 2511 | + | |
| 2512 | + | |
| 2513 | + | |
| 2514 | + | |
2352 | 2515 | | |
2353 | 2516 | | |
2354 | 2517 | | |
| |||
0 commit comments