A review found the tool classes - the core of the harness - bypassable in
several places where model output was pasted into a shell or trusted as an id.
Each fix below has a test that reproduces the original failure.
No shell for model data
- webfetch put the URL between '...' and ran it through popen: a quote in the
URL ran any command, from a tool that needed no consent. curl is now exec'd
with an argv, http(s) only, HTML stripped in C, stderr off the curses screen.
- webfetch is mutate: with read free, "read a key, fetch evil/?k=..." left the
machine without anybody being asked. websearch stays read (fixed host).
- kids: the parent-approval command got the model's arguments inside '...'
via system(); they are now "$1". The domain check reads the URL with the
same parser as the tool (duplicate keys) and refuses user@host URLs.
- delegate: the two copies of the child argv are one (exec_delegate). The ssh
path exec'd splinter with "ssh" as argv[0]; it now runs ssh and quotes every
word for the remote shell. A single delegate to a host now really runs there.
Approvals (ack)
- The id was the pid: a late yes stayed on disk and approved the next request
unseen. Ids are random, requests 0600 with O_EXCL, deleted when answered or
expired; an answer is refused after expiry; the first answer wins (link(2)).
- An ack dir owned by someone else or writable by others is refused.
- --ack accepted every word but "no" as yes ("nein" approved). Now strict.
- The terminal thread blocked in fgets after a phone answer; it is stoppable.
Secrets
- API key and Telegram token were in curl's argv, readable via ps. src/curl.c
passes URL and auth headers as a -K config on stdin (transport, telegram,
tg-ask.sh; its dead eval fallback is gone).
- 'run' and task_start no longer inherit splinter's keys ("run env"). 'run' got
its own process group, stdin /dev/null and SPLINTER_RUN_TIMEOUT (300 s).
MCP server
- Beyond 127.x it refuses to start without SPLINTER_MCP_TOKEN; connections
must begin with "AUTH <token>". SIGPIPE ignored, idle connections closed.
Crashes
- task_kill sent kill(-0) - SIGTERM to splinter's own process group - because
popen gave no pid. Tasks now have a pid and a process group; integer ids work.
- ui: a 3- or 4-byte UTF-8 character overflowed char[2] on every redraw
(now sp_ui_ascii_char, tested); the scroll offset was taken from one buffer
and applied to another, reading past its end.
Repo
- The test binaries are no longer tracked (.gitignore already said so).
make check: 23 test binaries, green, also under ASan/UBSan.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
33 lines
1.1 KiB
C
33 lines
1.1 KiB
C
/*
|
|
* splinter -- curl(1) without secrets on its command line.
|
|
*
|
|
* Copyright (c) 2026 Konrad Lother
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
#ifndef SPLINTER_CURL_H
|
|
#define SPLINTER_CURL_H
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include "splinter.h"
|
|
|
|
/*
|
|
* Start curl and return the read end of its stdout, or -1.
|
|
*
|
|
* args options that anybody may see in ps(1), NULL-terminated, without
|
|
* "curl" itself; may be NULL
|
|
* url the URL; it travels on stdin, because a Telegram URL is the token
|
|
* headers header lines that are secret ("Authorization: Bearer ..."),
|
|
* NULL-terminated; may be NULL
|
|
* quiet nonzero sends curl's stderr to /dev/null (a curses screen)
|
|
*
|
|
* stdin of curl is the config pipe, so it never reads the terminal.
|
|
*/
|
|
int sp_curl_start(const char *const *args, const char *url,
|
|
const char *const *headers, int quiet, pid_t *pid, struct sp_buf *err);
|
|
|
|
/* Append key = "value" in curl's config syntax; exposed for the tests. */
|
|
int sp_curl_config_line(struct sp_buf *b, const char *key, const char *value);
|
|
|
|
#endif /* SPLINTER_CURL_H */
|