Forráskód Böngészése

fix: the vendored curl never had the IDN support its Depends declared

Found while verifying the 0.16.0 packages, and it had been shipping for
three releases.

control.runner declares libidn2-0, and the note beside it called that a
deliberate trade: mail hostnames are usually ASCII, but breaking an
internationalised one to save a dependency is the wrong trade. The trade
was never made. The base image never installed libidn2-dev, so curl's
configure logged "Package 'libidn2' ... not found" and reported

  Features: AsynchDNS IPv6 Largefile SSL threadsafe UnixSockets

with no IDN, while objdump -p on the shipped runner shows no libidn2 among
its NEEDED libraries at all. An internationalised mail hostname would have
failed with nothing explaining why, and the one artefact anyone would have
checked said the opposite.

Fixed by adding libidn2-dev to the base image, so the declared dependency
becomes true - rather than dropping the dependency and degrading the
capability to match an accident.

Why it survived is worth more than the bug: this failure direction is
HARMLESS. A declared dependency the binary does not have costs one extra
package at install time, so nothing ever complains. Read the other way -
a dependency the binary needs and we forgot - it is the one that surfaces
as a service refusing to start on a customer box, and nothing tells the
two apart by reading the file. Two more benign instances turned up in the
same half hour: libz.so.1 is a real NEEDED library in no Depends list, and
libfmt.so.10 arrives only transitively through libspdlog1.15.

Also: devstack/run-tests.sh now DERIVES the client version from build.sh's
pin instead of hardcoding it. Its defaults said 2.12.0 and were eight
releases stale, which is exactly the failure its own warning describes -
the test path sitting on a different client than the release path, after
which a green suite is not evidence about the packages. Two places holding
one version was one too many. The database server default moves to the
deploy target for the same reason.

And two of my own checks on this binary were worthless while looking like
measurements, both recorded: strings|grep for protocol names returns
curl's full name TABLE whether or not a protocol is compiled in, so it
could not discriminate (the discriminating line is curl's own
"-- Protocols: imap imaps smtp smtps"); and I first ran ldd on the Void
dev host, which resolved against Void's libraries rather than Debian's -
the tell being that it reported both libfmt.so.10 and libfmt.so.12.
fszontagh 1 hónapja
szülő
commit
b63670716d
4 módosított fájl, 37 hozzáadás és 7 törlés
  1. 4 1
      CLAUDE.md
  2. 14 0
      packaging/Dockerfile.base
  3. 1 1
      packaging/build.sh
  4. 18 5
      packaging/devstack/run-tests.sh

+ 4 - 1
CLAUDE.md

@@ -436,7 +436,10 @@ docker run -d --name svapi-dev -p 8080:8080 -e SMARTBOTIC_VECTORAPI_KEY=dev svap
 - **QuickJS's job queue belongs to the `JSRuntime`, not the `JSContext`.** A fresh context per run is therefore *not* enough to isolate tenants: a run that times out mid-microtask leaves its jobs queued, and they would execute inside the next tenant's run. The core flushes them with the deadline forced into the past and marks the runtime `poisoned()` if anything survives; the pool destroys a poisoned runtime instead of leasing it out. An OOM poisons it too.
 - **`/etc/smartbotic-vectorapi` must stay mode 0751, not 0750.** The runner runs as its own user and needs `+x` to traverse the directory to `runner.json`; it still cannot list it, and the server's `0640` files stay unreadable to it. Both `server.postinst` and `runner.postinst` set it, and a server upgrade resetting it to `0750` breaks the runner on its **next restart** - a failure that surfaces weeks later with no obvious cause.
 - **The dev host's clang and the release GCC disagree about overload ambiguity, and the release toolchain is the only one that counts.** A braced list passed to `imapUidFetch` is viable for BOTH overloads - `{7, 9}` is either the set `7,9` or the single range `7:9`, and `{uid}` is either one uid or the range `uid:0` - so the two readings are DIFFERENT COMMANDS. clang silently picks one, GCC refuses the call, and the whole mail surface therefore compiled cleanly on the host for days and then failed the first release build it ever saw. Call such an overload set with an explicit vector type. The lesson is bigger than the call: `scripts/host-build.sh` passing is not evidence that the `.deb` will build, so a feature is not finished until the Docker path has compiled it.
-- **The deb `Depends` lists are HAND-MAINTAINED** - `create-debs.sh` copies each `control.*` template verbatim and never runs `dpkg-shlibdeps`, so a new shared-library dependency does **not** appear by itself; it surfaces as a service that refuses to start on a customer box. The mail surface added two to `control.runner`, both confirmed with `ldd` against the built binary rather than guessed: **`ca-certificates`**, because the vendored curl detects the CA bundle at CONFIGURE time and bakes the path in, and with TLS verification always on a missing bundle makes *every* mail connection fail as `mail_tls_untrusted` (which reads as a broken mail server, not a missing package); and **`libidn2-0`**, because the vendored curl keeps IDN support. IDN is deliberately not compiled out - mail hostnames are usually ASCII, but breaking an internationalised one to save a dependency is the wrong trade. **zlib, zstd and brotli are deliberately absent**: they are HTTP content encodings, HTTP is compiled out of the vendored curl, and leaving them enabled made them real package dependencies for capabilities the code cannot reach.
+- **The deb `Depends` lists are HAND-MAINTAINED** - `create-debs.sh` copies each `control.*` template verbatim and never runs `dpkg-shlibdeps`, so a new shared-library dependency does **not** appear by itself; it surfaces as a service that refuses to start on a customer box. The mail surface added two to `control.runner`, both confirmed with `ldd` against the built binary rather than guessed: **`ca-certificates`**, because the vendored curl detects the CA bundle at CONFIGURE time and bakes the path in, and with TLS verification always on a missing bundle makes *every* mail connection fail as `mail_tls_untrusted` (which reads as a broken mail server, not a missing package); and **`libidn2-0`**, because the vendored curl keeps IDN support. IDN is deliberately not compiled out - mail hostnames are usually ASCII, but breaking an internationalised one to save a dependency is the wrong trade.
+    **THAT TRADE WAS DECLARED AND NEVER ACTUALLY MADE, FOR THREE RELEASES, AND THE `Depends` LINE IS WHAT MADE IT LOOK DELIVERED.** Measured 2026-10-22 while verifying the 0.16.0 packages: the base image never installed `libidn2-dev`, so curl's configure logged `Package 'libidn2' ... not found` and reported **`Features: AsynchDNS IPv6 Largefile SSL threadsafe UnixSockets`** - no IDN - while `objdump -p` on the shipped runner showed **no libidn2 among its NEEDED libraries** at all. So an internationalised mail hostname would have failed with nothing explaining why, and the only artefact anyone would have checked said the opposite. `libidn2-dev` is now in `Dockerfile.base` and curl reports IDN; verify it after any base rebuild from curl's own `-- Features:` line.
+    **This is the hand-written-`Depends` failure in its most flattering direction, and it is worth more than the bug.** A declared dependency the binary does NOT have is harmless at install time - one extra package - which is exactly why nothing ever complained, and why it survived every release. **A `Depends` list is a statement of what we BELIEVE the binary needs; only `objdump -p` or `dpkg-shlibdeps` says what it needs.** The same list read in the opposite direction - a dependency the binary needs and we forgot - is the one that surfaces as a service refusing to start on a customer box, and nothing distinguishes the two by reading the file. Two more instances of the same shape were found in the same half hour: `libz.so.1` is a real NEEDED library and appears in no `Depends` (harmless, since zlib is effectively always present, but it means the note calling zlib "deliberately absent" describes our curl flags rather than the binary), and `libfmt.so.10` likewise arrives only transitively through `libspdlog1.15`.
+    **And two of my OWN checks on this binary were worthless in ways worth recording, because both looked like measurements.** `strings | grep` for the protocol names returns curl's full protocol NAME TABLE whether or not a protocol is compiled in, so it listed `https`, `pop3` and `sftp` and could not have told the difference - a check that cannot discriminate. The discriminating one is curl's own configure line, `-- Protocols: imap imaps smtp smtps`. And I first ran `ldd` on the extracted binary **on the Void dev host**, which resolved against Void's libraries rather than Debian's; the tell was that it reported BOTH `libfmt.so.10` and `libfmt.so.12`. Run it inside the Debian container, or read `objdump -p`, which needs no loader at all. **zlib, zstd and brotli are deliberately absent**: they are HTTP content encodings, HTTP is compiled out of the vendored curl, and leaving them enabled made them real package dependencies for capabilities the code cannot reach.
 - **Installing the runner does not enable functions.** `config.json` ships with no `functions.runners` endpoints, and the server disables the function routes when the list is empty (answering 503). An operator has to add the endpoint by hand, and set the same `SVAPI_RUNNER_TOKEN` in both `vectorapi.env` and `runner.env`.
 - **UPSTREAM PIN REVIEW, 2026-10-09.** Both pins were checked against what this service actually reaches, which is the standing discipline here rather than chasing version numbers.
   - **curl 8.23.0: JUDGED ITEM BY ITEM NOW THAT THE EMBARGO HAS LIFTED, AND THE HIGH IS NOT OUR EXPOSURE.** This entry used to say the bump was "REQUIRED and not optional" with "the HIGH one is unknown"; the details are public since 2026-10-14 and the picture is nearly the opposite of what the severity implied. **CVE-2026-92392 (HIGH) is a use-after-free in HTTP/2 UPLOAD handling** - a malicious server's `RST_STREAM` with `HTTP_1_1_REQUIRED` or `REFUSED_STREAM` frees a `struct Curl_easy` still in use, proven convertible to RCE under exact conditions. **We cannot reach it, for two independent reasons read off our own build rather than from prose: `CURL_DISABLE_HTTP ON` and `USE_NGHTTP2 OFF`** (`runner/CMakeLists.txt`). There is no HTTP in this curl at all, let alone HTTP/2. Of the other twenty-one, every one is rated Low and twenty are unreachable here, each ruled out by a specific setting or a missing call rather than by assumption: cookies, ALTSVC and HSTS are `CURL_DISABLE_*` (5 CVEs); `CURL_DISABLE_PROXY` (1); `CURL_USE_GSSAPI OFF` plus `CURL_DISABLE_NTLM` kill the three Negotiate ones; FTP, TFTP, POP3 and WEBSOCKETS are in the disable loop (3); OpenSSL rather than wolfSSL or GnuTLS (2); no libssh2 or libssh, so SSH `known_hosts` and the SFTP/SCP redirect are out (2); `BUILD_CURL_EXE OFF`, so the two flaws in the command-line TOOL cannot ship in a library-only build; and `curl_mime_*`, `CURLOPT_INTERFACE`, `CURLOPT_SSLCERT` and `CURLINFO_EFFECTIVE_URL` appear NOWHERE in `runner/src` (4) - we build MIME ourselves in `net/mime_build.cpp`.

+ 14 - 0
packaging/Dockerfile.base

@@ -7,8 +7,22 @@ ENV DEBIAN_FRONTEND=noninteractive
 RUN apt-get update && apt-get install -y --no-install-recommends \
         ca-certificates curl gnupg cmake ninja-build g++ pkg-config git \
         nlohmann-json3-dev libspdlog-dev libfmt-dev libssl-dev libsystemd-dev \
+        libidn2-dev \
         protobuf-compiler libprotobuf-dev libgrpc++-dev protobuf-compiler-grpc \
     && rm -rf /var/lib/apt/lists/*
+# libidn2-dev is here so the VENDORED curl really gets IDN, which control.runner
+# has always DECLARED (`libidn2-0`) and this file's own note called a deliberate
+# trade: "mail hostnames are usually ASCII, but breaking an internationalised one
+# to save a dependency is the wrong trade." Measured 2026-10-22 and the trade was
+# never actually made - without this package curl's configure logged "Package
+# 'libidn2' ... not found" and reported `Features: AsynchDNS IPv6 Largefile SSL
+# threadsafe UnixSockets` with no IDN, while `objdump -p` on the shipped runner
+# showed no libidn2 among its NEEDED libraries. So the hand-written Depends line
+# was evidence of INTENT and was read as evidence of fact, and an
+# internationalised mail hostname would have failed with nothing explaining why.
+# Verify after any base rebuild by reading curl's own `-- Features:` line from
+# the build log, never the Depends list.
+#
 # Note: the gRPC/protobuf dev packages above are required so that the cmake
 # config shipped by libsmartbotic-db-client-dev can resolve `find_dependency(gRPC
 # CONFIG)`. Without protobuf-compiler-grpc, trixie's gRPCTargets.cmake references

+ 1 - 1
packaging/build.sh

@@ -122,7 +122,7 @@ Environment variables:
   BUILD_JOBS           Parallel build jobs (default: nproc)
   DEB_REPO_DIR         Path to smartbotics-deb-repo (default: /data/dev/smartbotics/smartbotics-deb-repo)
   DB_CLIENT_VERSION    libsmartbotic-db-client version to build against; must match
-                       the deploy target (default: 2.17.2-1)
+                       the deploy target (default: 2.20.0-1)
 EOF
     exit 0
 }

+ 18 - 5
packaging/devstack/run-tests.sh

@@ -14,11 +14,24 @@ set -euo pipefail
 REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
 BASE_IMAGE="${BASE_IMAGE:-smartbotic-vectorapi-build-base:debian13}"
 DEB_REPO_DIR="${DEB_REPO_DIR:-/data/dev/smartbotics/smartbotics-deb-repo}"
-DB_DEB="${DB_DEB:-$DEB_REPO_DIR/dist/smartbotic-database_2.12.0-1_amd64.deb}"
-# The base image pins a client version; tests must compile against the same one
-# the release does, so the dev package is installed here rather than assumed.
-CLIENT_DEV_DEB="${CLIENT_DEV_DEB:-$DEB_REPO_DIR/dist/libsmartbotic-db-client-dev_2.12.0-1_amd64.deb}"
-CLIENT_DEB="${CLIENT_DEB:-$DEB_REPO_DIR/dist/libsmartbotic-db-client_2.12.0-1_amd64.deb}"
+# The client version is DERIVED from build.sh's pin rather than written here.
+# These used to be hardcoded at 2.12.0 and were eight releases stale, which is
+# the exact failure this file's own warning describes: the TEST path can sit on
+# a different client than the RELEASE path, and then a green suite is not
+# evidence about the packages. Two places holding one version is one too many,
+# so there is now a single source and this reads it.
+DB_CLIENT_VERSION="${DB_CLIENT_VERSION:-$(
+    sed -n 's/^DB_CLIENT_VERSION="\${DB_CLIENT_VERSION:-\(.*\)}"$/\1/p' "$REPO/packaging/build.sh"
+)}"
+[[ -n "$DB_CLIENT_VERSION" ]] || {
+    echo "could not read DB_CLIENT_VERSION out of packaging/build.sh" >&2; exit 1; }
+# The DATABASE server version is a separate choice from the client: default to
+# the deploy target so the integration tests meet the server prod will run,
+# rather than whichever one happened to be current when this line was written.
+DB_VERSION="${DB_VERSION:-2.20.1-1}"
+DB_DEB="${DB_DEB:-$DEB_REPO_DIR/dist/smartbotic-database_${DB_VERSION}_amd64.deb}"
+CLIENT_DEV_DEB="${CLIENT_DEV_DEB:-$DEB_REPO_DIR/dist/libsmartbotic-db-client-dev_${DB_CLIENT_VERSION}_amd64.deb}"
+CLIENT_DEB="${CLIENT_DEB:-$DEB_REPO_DIR/dist/libsmartbotic-db-client_${DB_CLIENT_VERSION}_amd64.deb}"
 FILTER="${1:-}"
 # BUILD_RUNNER=ON also builds and tests the QuickJS runner. Off by default
 # because it vendors QuickJS from GitHub at configure time.