Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"docs/issues/*/2850-non-negative-number-of-bytes/evidence/*.txt",
"docs/issues/*/2915-2912-si-3-http-tracker-request-errors/evidence/*.txt",
"docs/issues/*/2916-2912-si-4-tracker-core/evidence/*.txt",
"docs/issues/*/2993-secrets-and-client-error-text/evidence/*.txt",
".github/labels.json",
"/project-words.txt",
"repomix-output.xml",
Expand Down

Large diffs are not rendered by default.

220 changes: 220 additions & 0 deletions docs/issues/drafts/2993-si-b-client-error-text-policy/ISSUE.md

Large diffs are not rendered by default.

311 changes: 311 additions & 0 deletions docs/issues/open/2993-secrets-and-client-error-text/EPIC.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
### V1-V5 private tracker, sqlite
--- V1 announce, unregistered key
d14:failure reason141:Tracker authentication error: Failed to read key: TestPeerKey000000000000000000001, packages/tracker-core/src/authentication/service.rs:98:27e
--- V1 announce, no key
d14:failure reason108:Tracker authentication error: Missing authentication key, packages/http-core/src/services/announce.rs:308:27e
--- V1 announce, 14-character key
d14:failure reason110:Tracker authentication error: Invalid format for authentication key param: expected 32 alphanumeric characterse
--- V2 REST add 14-character key
Invalid URL: invalid auth key: string "ShortTestKey01", Invalid key length. Key must be have 32 chars, packages/tracker-core/src/authentication/handler.rs:108:46 [400]
--- V2 REST delete malformed key
Invalid auth key id param "BadTestKey" [400]
--- V3 REST wrong token in query
Unhandled rejection: Err { reason: "token not valid" } [500]
--- V4 REST generate key (reply not shown)
[200]
--- V5 REST duplicate key (sqlite)
{"key":"TestPeerKey000000000000000000002","valid_until":1795358731,"expiry_time":"2026-11-22 14:45:31 UTC"} [200]
Unhandled rejection: Err { reason: "failed to add key: The Sqlite3 query was malformed: error returned from database: (code: 2067) UNIQUE constraint failed: keys.key, packages/tracker-core/src/databases/driver/sqlite/auth_key_store.rs:74:22, packages/tracker-core/src/authentication/handler.rs:103:50" } [500]
--- V5 REST malformed JSON
Failed to parse the request body as JSON: key must be a string at line 1 column 2 [400]
--- V5 REST unknown path
[404]
--- log: uri fields holding a test key or token
uri=/announce/ShortTestKey01?info_hash=%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00&peer_id=-qB00000000000000001&port=17548&left=0
uri=/announce/TestPeerKey000000000000000000001?info_hash=%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00&peer_id=-qB00000000000000001&port=17548&left=0
uri=/api/v1/key/BadTestKey
uri=/api/v1/stats?token=WrongTestToken0001
--- log: lines holding the admin token sent in the header: 0 (the startup configuration dump prints it as ***)
--- log: 'Generated key' lines: 1; lines holding the generated key: 1
2026-11-22T14:43:51.142622Z DEBUG request{method=POST uri=/api/v1/key/3600 version=HTTP/1.1}: torrust_tracker_core::authentication::key: Generated key: <the generated key>, valid for: 3600s seconds
--- log: lines for the 500 reply
2026-11-22T14:43:51.138915Z ERROR request{method=GET uri=/api/v1/stats?token=WrongTestToken0001 version=HTTP/1.1}: API: response latency_ms=0 status_code=500 Internal Server Error server_socket_addr=127.0.0.1:41212 service_binding=http://127.0.0.1:41212/ request_id=79d28710-5453-4595-b6a5-7aaf83e34e8c

### V6 UDP, public listed tracker, sqlite
--- UDP announce, not whitelisted
tracker announce error: Tracker core whitelist error: The torrent: 0000000000000000000000000000000000000000, is not whitelisted, packages/tracker-core/src/whitelist/authorization.rs:61:23
--- UDP announce, wrong connection id
tracker announce error: Connection cookie error: cookie value is expired: -0.0…010544892055975403, expected > 1795358512.2066972
--- UDP 3-byte packet
error parsing request: SendableRequestParseError { message: "Couldn't parse action", opt_connection_id: None, opt_transaction_id: None }
--- HTTP announce, not whitelisted
d14:failure reason158:Tracker whitelist error: The torrent: 0000000000000000000000000000000000000000, is not whitelisted, packages/tracker-core/src/whitelist/authorization.rs:61:23e

### V7 configuration errors
--- pw-int
Failed processing the configuration: invalid type: found signed int `987654321`, expected a string for key "default.core.database.password" in TOML source string, packages/configuration/src/v3_0_0/mod.rs:409:28, packages/configuration/src/lib.rs:258:56
--- token-int
Failed processing the configuration: invalid type: found signed int `424242`, expected a string for key "default.http_api.access_tokens.admin" in TOML source string, packages/configuration/src/v3_0_0/mod.rs:409:28, packages/configuration/src/lib.rs:258:56

### V8 database server messages (MySQL 8.0, PostgreSQL 16)
--- mysql-bad (wrong credentials)
The MySQL query was malformed: error returned from database: 1045 (28000): Access denied for user 'db_user'@'172.17.0.1' (using password: YES), packages/tracker-core/src/databases/driver/mysql/schema_migrator.rs:86:41
--- pg-bad (wrong credentials)
Failed to apply PostgreSQL schema migrations: while executing migrations: error returned from database: password authentication failed for user "db_user", packages/tracker-core/src/databases/driver/postgres/schema_migrator.rs:12:9
--- mysql duplicate key
{"key":"TestPeerKey000000000000000000003","valid_until":1795358744,"expiry_time":"2026-11-22 14:45:44 UTC"} [200]
Unhandled rejection: Err { reason: "failed to add key: The MySQL query was malformed: error returned from database: 1062 (23000): Duplicate entry 'TestPeerKey000000000000000000003' for key 'keys.key', packages/tracker-core/src/databases/driver/mysql/auth_key_store.rs:72:22, packages/tracker-core/src/authentication/handler.rs:103:50" } [500]
log lines holding the key: 1
2026-11-22T14:44:04.850783Z DEBUG request{method=POST uri=/api/v1/keys version=HTTP/1.1}: torrust_located_error: The MySQL query was malformed: error returned from database: 1062 (23000): Duplicate entry 'TestPeerKey000000000000000000003' for key 'keys.key', packages/tracker-core/src/databases/driver/mysql/auth_key_store.rs:72:2
--- pg duplicate key
{"key":"TestPeerKey000000000000000000003","valid_until":1795358746,"expiry_time":"2026-11-22 14:45:46 UTC"} [200]
Unhandled rejection: Err { reason: "failed to add key: The PostgreSQL query was malformed: error returned from database: duplicate key value violates unique constraint \"keys_key_key\", packages/tracker-core/src/databases/driver/postgres/auth_key_store.rs:72:22, packages/tracker-core/src/authentication/handler.rs:103:50" } [500]
log lines holding the key: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env bash
# Usage: run.sh <tracker-binary> <work-dir>. Reproduces the EPIC #2993 inventory cases. Test values only.
set -u
BIN=$1; W=$2; mkdir -p "$W"; cd "$W" || exit 1
strip(){ sed 's/\x1b\[[0-9;]*m//g'; }
hdr='[metadata]
app = "torrust-tracker"
purpose = "configuration"
schema_version = "3.0.0"
[logging]
trace_filter = "debug"
trace_style = "full"
'
start(){ ("$BIN" --config-toml-path "$1" > "$2" 2>&1 & echo $! > "$2.pid"); for _ in $(seq 1 30); do curl -s -o /dev/null "http://127.0.0.1:$3/api/health_check" && return; sleep 1; done; }
stop(){ kill "$(cat "$1.pid")" 2>/dev/null; sleep 1; }
H='Authorization: Bearer TestAdminToken0001'
IH='info_hash=%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00&peer_id=-qB00000000000000001&port=17548&left=0'

echo "### V1-V5 private tracker, sqlite"
printf '%s[core]\nlisted = false\nprivate = true\n[core.database]\ndriver = "sqlite3"\npath = "%s/private.db"\n[http_api]\nbind_address = "127.0.0.1:41212"\n[http_api.access_tokens]\nadmin = "TestAdminToken0001"\n[[http_trackers]]\nbind_address = "127.0.0.1:47070"\n[health_check_api]\nbind_address = "127.0.0.1:41313"\n' "$hdr" "$W" > private.toml
rm -f private.db*; start private.toml private.log 41212
echo "--- V1 announce, unregistered key"; curl -s "http://127.0.0.1:47070/announce/TestPeerKey000000000000000000001?$IH"; echo
echo "--- V1 announce, no key"; curl -s "http://127.0.0.1:47070/announce?$IH"; echo
echo "--- V1 announce, 14-character key"; curl -s "http://127.0.0.1:47070/announce/ShortTestKey01?$IH"; echo
echo "--- V2 REST add 14-character key"; curl -s -X POST -H "$H" -H 'content-type: application/json' -d '{"key":"ShortTestKey01","seconds_valid":100}' -w ' [%{http_code}]\n' http://127.0.0.1:41212/api/v1/keys
echo "--- V2 REST delete malformed key"; curl -s -X DELETE -H "$H" -w ' [%{http_code}]\n' http://127.0.0.1:41212/api/v1/key/BadTestKey
echo "--- V3 REST wrong token in query"; curl -s -w ' [%{http_code}]\n' "http://127.0.0.1:41212/api/v1/stats?token=WrongTestToken0001"
echo "--- V4 REST generate key (reply not shown)"; curl -s -o gen.json -X POST -H "$H" -w '[%{http_code}]\n' http://127.0.0.1:41212/api/v1/key/3600
echo "--- V5 REST duplicate key (sqlite)"; for _ in 1 2; do curl -s -X POST -H "$H" -H 'content-type: application/json' -d '{"key":"TestPeerKey000000000000000000002","seconds_valid":100}' -w ' [%{http_code}]\n' http://127.0.0.1:41212/api/v1/keys; done
echo "--- V5 REST malformed JSON"; curl -s -X POST -H "$H" -H 'content-type: application/json' -d '{bad' -w ' [%{http_code}]\n' http://127.0.0.1:41212/api/v1/keys
echo "--- V5 REST unknown path"; curl -s -o /dev/null -X GET -H "$H" -w '[%{http_code}]\n' http://127.0.0.1:41212/api/v1/key/abc/extra
stop private.log
echo "--- log: uri fields holding a test key or token"; strip < private.log | grep -o -E 'uri=[^ ]*(TestPeerKey|ShortTestKey|BadTestKey|WrongTestToken)[^ ]*' | sort -u
echo "--- log: lines holding the admin token sent in the header: $(strip < private.log | grep -c TestAdminToken0001) (the startup configuration dump prints it as ***)"
GK=$(sed -E 's/.*"key":"([^"]+)".*/\1/' gen.json); echo "--- log: 'Generated key' lines: $(strip < private.log | grep -c 'Generated key'); lines holding the generated key: $(strip < private.log | grep -c "$GK")"
strip < private.log | grep 'Generated key' | sed "s/$GK/<the generated key>/" | cut -c1-200
echo "--- log: lines for the 500 reply"; strip < private.log | grep -E 'status_code=500' | head -1 | cut -c1-330

echo; echo "### V6 UDP, public listed tracker, sqlite"
printf '%s[core]\nlisted = true\nprivate = false\n[core.database]\ndriver = "sqlite3"\npath = "%s/public.db"\n[http_api]\nbind_address = "127.0.0.1:41212"\n[http_api.access_tokens]\nadmin = "TestAdminToken0001"\n[[udp_trackers]]\nbind_address = "127.0.0.1:46969"\n[[http_trackers]]\nbind_address = "127.0.0.1:47070"\n[health_check_api]\nbind_address = "127.0.0.1:41313"\n' "$hdr" "$W" > public.toml
rm -f public.db*; start public.toml public.log 41212
python3 -I "$(dirname "$0")/udp_probe.py" 46969
echo "--- HTTP announce, not whitelisted"; curl -s "http://127.0.0.1:47070/announce?$IH"; echo
stop public.log
echo "--- private mode refuses UDP:"; strip < private.log | grep -o 'Could not start UDP trackers.*' | head -1

echo; echo "### V7 configuration errors"
db='[core]\nlisted = false\nprivate = false\n[core.database]\ndriver = "mysql"\nhost = "127.0.0.1"\nuser = "db_user"\ndatabase = "torrust_tracker"\n'
printf "%s${db}port = 3306\npassword = 987654321\n" "$hdr" > pw-int.toml
printf "%s${db}port = 3306\npassword = \"x\"\n[http_api]\nbind_address = \"127.0.0.1:0\"\n[http_api.access_tokens]\nadmin = 424242\n" "$hdr" > token-int.toml
# shellcheck disable=SC2016 # the backticks are literal sed text
for n in pw-int token-int; do echo "--- $n"; timeout 20 "$BIN" --config-toml-path $n.toml 2>&1 | strip | grep '^Tracker startup failed' | sed 's/.*explicit configuration file `[^`]*`: //'; done

echo; echo "### V8 database server messages (MySQL 8.0, PostgreSQL 16)"
docker run -d --rm --name ev2993-mysql -e MYSQL_ROOT_PASSWORD=TestDbPassword01 -e MYSQL_DATABASE=torrust_tracker -p 127.0.0.1:33061:3306 mysql:8.0 >/dev/null
docker run -d --rm --name ev2993-pg -e POSTGRES_PASSWORD=TestDbPassword01 -e POSTGRES_DB=torrust_tracker -p 127.0.0.1:54321:5432 postgres:16 >/dev/null
for _ in $(seq 1 60); do docker exec ev2993-mysql mysql -h127.0.0.1 -uroot -pTestDbPassword01 -e 'select 1' >/dev/null 2>&1 && break; sleep 2; done
for _ in $(seq 1 30); do docker exec ev2993-pg pg_isready -q && break; sleep 2; done; sleep 3
mk(){ printf '%s[core]\nlisted = false\nprivate = true\n[core.database]\ndriver = "%s"\nhost = "127.0.0.1"\nport = %s\nuser = "%s"\npassword = "%s"\ndatabase = "torrust_tracker"\n[http_api]\nbind_address = "127.0.0.1:41212"\n[http_api.access_tokens]\nadmin = "TestAdminToken0001"\n[health_check_api]\nbind_address = "127.0.0.1:41313"\n' "$hdr" "$1" "$2" "$3" "$4" > "$5"; }
mk mysql 33061 db_user WrongTestPassword mysql-bad.toml; mk postgresql 54321 db_user WrongTestPassword pg-bad.toml
for n in mysql-bad pg-bad; do echo "--- $n (wrong credentials)"; timeout 40 "$BIN" --config-toml-path $n.toml 2>&1 | strip | grep '^Tracker startup failed' | sed 's/.*schema permissions: //'; done
mk mysql 33061 root TestDbPassword01 mysql.toml; mk postgresql 54321 postgres TestDbPassword01 pg.toml
for n in mysql pg; do echo "--- $n duplicate key"; start $n.toml $n.log 41212; for _ in 1 2; do curl -s -X POST -H "$H" -H 'content-type: application/json' -d '{"key":"TestPeerKey000000000000000000003","seconds_valid":100}' -w ' [%{http_code}]\n' http://127.0.0.1:41212/api/v1/keys; done; stop $n.log; echo "log lines holding the key: $(strip < $n.log | grep -c TestPeerKey000000000000000000003)"; strip < $n.log | grep TestPeerKey000000000000000000003 | cut -c1-330; done
docker stop ev2993-mysql ev2993-pg >/dev/null
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Usage: python3 -I udp_probe.py <port>. Sends a BEP 15 connect, then an announce with the
# connection id, an announce with a wrong connection id, and a 3-byte packet; prints each reply's message.
import socket, struct, sys
a = ("127.0.0.1", int(sys.argv[1]))
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.settimeout(4)
def rx():
try:
return s.recvfrom(2048)[0]
except OSError as e:
return repr(e)
def ann(c):
return (struct.pack(">QII", c, 1, 7) + b"\x00" * 20 + b"-qB00000000000000001"
+ struct.pack(">QQQiIIiH", 0, 0, 0, 0, 0, 0, -1, 6881))
s.sendto(struct.pack(">QII", 0x41727101980, 0, 9), a)
r = rx()
cid = struct.unpack(">Q", r[8:16])[0]
for label, pkt in (("announce, not whitelisted", ann(cid)), ("announce, wrong connection id", ann(cid ^ 0xFF)), ("3-byte packet", b"\x00\x01\x02")):
s.sendto(pkt, a)
r = rx()
print("--- UDP " + label)
print(r[8:].decode(errors="replace") if isinstance(r, bytes) else r)
Loading
Loading