diff --git a/7z/Dockerfile b/7z/Dockerfile index b38e3cb..f895374 100644 --- a/7z/Dockerfile +++ b/7z/Dockerfile @@ -3,9 +3,9 @@ ARG FILC_VERSION=0.687 ARG FILC_X86_64_SHA256=aab538401f78a47ab261ee79afed8c6b99e1d4848e263ae159a75b03c1288da1 ARG FILC_AARCH64_SHA256=f1337799051664f93c7712141deaebe78571ae96ffcf05563d517b89440bcbc0 -ARG SEVENZIP_VERSION=26.04 -ARG SEVENZIP_ARCHIVE_VERSION=2604 -ARG SEVENZIP_SHA256=9691944c0fe0d01bb49373a704fb983fd33bc98b1738695179dfbf99ac1734f6 +ARG SEVENZIP_VERSION=26.05 +ARG SEVENZIP_ARCHIVE_VERSION=2605 +ARG SEVENZIP_SHA256=0b6080b8c3e7a579161d2d495224c0e51c467576cb4c7048b0ab485ef44cc22e FROM ubuntu:24.04 AS build diff --git a/README.md b/README.md index 43b1d6d..6f8a708 100644 --- a/README.md +++ b/README.md @@ -376,7 +376,7 @@ delicate, and every one of them runs against the Fil-C binary. | Utility | Upstream suite | Result under Fil-C | | --- | --- | --- | | GNU tar | Autotest, 226 files | 208 pass, 36 skip | -| curl | 1712 enabled cases | 1712 pass | +| curl | 1715 enabled cases | 1715 pass | | GNU Wget | `tests/` + `testenv/`, 136 cases | 134 pass, 2 skip | | tmux | `regress/`, 174 cases (git only) | 174 pass | | gzip | 34 cases | 33 pass, 1 skip | @@ -693,8 +693,8 @@ than content-addressed image digests. | --- | --- | --- | | Fil-C (x86_64) | 0.687 | `aab538401f78a47ab261ee79afed8c6b99e1d4848e263ae159a75b03c1288da1` | | Fil-C (aarch64) | 0.687 | `f1337799051664f93c7712141deaebe78571ae96ffcf05563d517b89440bcbc0` | -| 7-Zip source | 26.04 | `9691944c0fe0d01bb49373a704fb983fd33bc98b1738695179dfbf99ac1734f6` | -| unRAR source | 7.3.1 | `634900842a3737d9cc15bbcc71d4c74cc713437e0bca296a573424fe5f2660ab` | +| 7-Zip source | 26.05 | `0b6080b8c3e7a579161d2d495224c0e51c467576cb4c7048b0ab485ef44cc22e` | +| unRAR source | 7.3.2 | `f61a1160d6e2ebbda2ad353c8e82f62ab4312f97fde23c6c2c982d25e0014f99` | | GNU tar source | 1.35 | `4d62ff37342ec7aed748535323930c7cf94acf71c3591882b26a7ea50f3edc16` | | GNU gzip source | 1.15 | `9aa0cc780dec156b8282844833b342ab7cb08c25d2cd9a1869cdd0df31deff48` | | bzip2 source | 1.0.8 | `ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269` | @@ -702,7 +702,7 @@ than content-addressed image digests. | Zstandard source | 1.5.7 | `eb33e51f49a15e023950cd7825ca74a4a2b43db8354825ac24fc1b7ee09e6fa3` | | curl source | 8.23.0 | `8dadd7d2536a314f982ad05a651b713f426bf7d02cc2c76cffb9796f2218e6c5` | | GNU Wget source | 1.25.0 | `766e48423e79359ea31e41db9e5c289675947a7fcf2efdcedb726ac9d0da3784` | -| OpenSSL source (curl, git, OpenSSH) | 4.0.3 | `325b5c806167c13b40b1ffeadfe0248197c00eccc4cf123ec1e28d2d2fd216d9` | +| OpenSSL source (curl, git, OpenSSH) | 4.1.0 | `50c17baf54cb008f6ce42d50deb4b28050a1aad711636cabd4b241c7e90cc2fd` | | OpenSSL source (wget) | 3.6.5 | `a2157c2830efdec3788939b00c9b0638306d3f0bbb76dc4832ee503bb397df98` | | zlib source | 1.3.2 | `bb329a0a2cd0274d05519d61c667c062e06990d72e125ee2dfa8de64f0119d16` | | libunistring source | 1.5 | `fe89007a8a414ae4790b816b86859e877d3ab135db3c37f06541ff7e85ac344b` | @@ -710,7 +710,7 @@ than content-addressed image digests. | libpsl source | 0.23.3 | `93941f85a1e7bd593fa94f299233cb5dfc91cd144fd9a78a6ceb75001c5b03be` | | PCRE2 source | 10.49 | `929f0b20e62879252a15886b06c89f1edef61a363cbd5826fb041080a5e557ae` | | c-ares source | 1.34.9 | `9364b70a12eb59a06830fb488d9357f90100dff0d98b23ea3593a183d43e6f2f` | -| GNU nano source | 9.2 | `05ecb99247b782e8a5b3a25ed4101dd034b0236902f7449bc9795b717642f7e9` | +| GNU nano source | 9.3 | `a9affc52c9596ee0682bcdd4ceb3c0b235eb221d83d733dfd9b0dff45897cb0d` | | ncurses source | 6.6 | `355b4cbbed880b0381a04c46617b7656e362585d52e9cf84a67e2009b749ff11` | | file source | 5.48 | `ed14656883b23a364b4057c05595d93252da9bc473d30106519519d0da141283` | | tmux source | 3.8 | `e79c699c7e949dccd0a4a125e17b8d1261e311b16979dbc8eb34542f3966d82e` | @@ -718,7 +718,7 @@ than content-addressed image digests. | libevent source | 2.1.13 | `f7e9383b8c0baa81b687e5b5eecc01beefaf1b19b64151d95ed61647fe7a315c` | | utf8proc source | 2.12.0 | `a393fbef160835fb315bc3e91ba8d86f7a73a7cec9e6198b6c60b848b498bfeb` | | Git source | 2.56.0 | `26c56c296b38c0695b26fa95f475f1d01704d2d38e73465ca30b0b2f5dc789d3` | -| Expat source | 2.9.0 | `16afbb9cefead2aa278105cf27d9f597bde7fbf3dbb85015857ca7ca6a4e89ba` | +| Expat source | 2.10.0 | `5466a341f9c692ef7a958a6881311be597f8e1ce345984cf78414f54793dea4c` | | OpenSSH portable source | 10.6p1 | `a9dc9565dffe8640f64d863cd29a32bc4a3dbdec0566a7fc44c5d6ee767d5f39` | The Dockerfile frontend, Ubuntu base image, and Ubuntu packages installed in @@ -872,9 +872,12 @@ recovery. ├── bzip2/ │ └── Dockerfile ├── curl/ -│ └── Dockerfile +│ ├── Dockerfile +│ ├── test-name-constraints.py +│ └── patches/ ├── git/ │ ├── Dockerfile +│ ├── test-name-constraints.py │ └── patches/ ├── gzip/ │ └── Dockerfile @@ -1120,10 +1123,10 @@ nano vendors gnulib's x87 control-word helper. On x86-64 its long-double formatting path normally saves and restores the precision control with inline `fnstcw` and `fldcw`, whose memory operands Fil-C turns into run-time traps. Fil-C's musl fenv implementation cannot change x87 precision, so the default -extended precision remains in effect. A scoped patch omits the redundant save -and restore under Fil-C. gzip 1.15 no longer vendors that helper, so it needs no -equivalent patch. Both Dockerfiles reject the compiler's trap marker if any -unsupported inline assembly remains. +extended precision remains in effect. nano 9.3's gnulib already omits the +redundant save and restore under Fil-C, so no local patch is needed. gzip 1.15 +no longer vendors that helper either. Both Dockerfiles reject the compiler's +trap marker if any unsupported inline assembly remains. gzip 1.15 also moved `` below `gzip.h`, which defines a legacy `head` macro. Pizfix's AArch64 signal-context structs use the same field name, so a @@ -1154,6 +1157,20 @@ mismatch fails the static link with a bare `cannot find -lssl`; and `make install_ssldirs` has to follow `install_sw`, or `openssl.cnf` is missing and the build's own TLS test cannot generate a certificate. +curl 8.23 still implements common-name hostname fallback itself, while OpenSSL +4.1 no longer checks DNS name constraints on the subject without an explicit +opt-in. Both libcurl builds (curl and git) set +`X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT` so a constrained CA cannot authenticate +a CN-only certificate outside its permitted names. This also enforces CN +constraints when a SAN is present, so a constrained certificate needs both +names to be permitted. Each build generates a local constrained-CA fixture +and exercises its shipped, stripped client: permitted CN and SAN certificates +must work, while forbidden CN, SAN, and mixed CN/SAN certificates must fail +with a certificate-verification error. A hostname-mismatch case also requires +SAN matching to take precedence over a matching CN. The fixture scripts and +libcurl patches are duplicated to keep the two Docker build contexts +self-contained. + curl needs the same libtool treatment as XZ, for the same reason: a plain `-static` yields a dynamically loaded Fil-C executable, and `-Wc,-static` at `make` time is what produces the static PIE. Overriding `LDFLAGS` there diff --git a/curl/Dockerfile b/curl/Dockerfile index 500f0d9..36cec05 100644 --- a/curl/Dockerfile +++ b/curl/Dockerfile @@ -5,8 +5,8 @@ ARG FILC_X86_64_SHA256=aab538401f78a47ab261ee79afed8c6b99e1d4848e263ae159a75b03c ARG FILC_AARCH64_SHA256=f1337799051664f93c7712141deaebe78571ae96ffcf05563d517b89440bcbc0 ARG ZLIB_VERSION=1.3.2 ARG ZLIB_SHA256=bb329a0a2cd0274d05519d61c667c062e06990d72e125ee2dfa8de64f0119d16 -ARG OPENSSL_VERSION=4.0.3 -ARG OPENSSL_SHA256=325b5c806167c13b40b1ffeadfe0248197c00eccc4cf123ec1e28d2d2fd216d9 +ARG OPENSSL_VERSION=4.1.0 +ARG OPENSSL_SHA256=50c17baf54cb008f6ce42d50deb4b28050a1aad711636cabd4b241c7e90cc2fd ARG CURL_VERSION=8.23.0 ARG CURL_SHA256=8dadd7d2536a314f982ad05a651b713f426bf7d02cc2c76cffb9796f2218e6c5 @@ -42,10 +42,12 @@ RUN apt-get update \ libc6-dev \ linux-libc-dev \ make \ + openssl \ patch \ patchelf \ perl \ pkg-config \ + python3 \ stunnel4 \ xz-utils \ && rm -rf /var/lib/apt/lists/* @@ -128,6 +130,9 @@ RUN curl -fsSL ${FETCH_RETRY} -o /tmp/curl.tar.xz \ && tar --strip-components=1 -xJf /tmp/curl.tar.xz \ && rm /tmp/curl.tar.xz +COPY patches/0001-enforce-cn-name-constraints-with-openssl-4.1.patch /tmp/curl-name-constraints.patch +RUN patch --batch --forward -p1 < /tmp/curl-name-constraints.patch + # The CA bundle is read from the platform rather than embedded. curl's # --with-ca-embed would compile a copy into the executable and then prefer it # over the system store instead of falling back to it, so a host's certificate @@ -253,6 +258,9 @@ RUN set -e; \ if [ "${ok}" != yes ]; then echo "HTTPS check failed:"; cat /tmp/tls.err; exit 1; fi; \ echo "curl verifies a public certificate from the system trust store" +COPY test-name-constraints.py /tests/test-name-constraints.py +RUN python3 /tests/test-name-constraints.py curl /artifact/bin/curl + FROM scratch AS artifact ARG FILC_VERSION diff --git a/curl/patches/0001-enforce-cn-name-constraints-with-openssl-4.1.patch b/curl/patches/0001-enforce-cn-name-constraints-with-openssl-4.1.patch new file mode 100644 index 0000000..ce30367 --- /dev/null +++ b/curl/patches/0001-enforce-cn-name-constraints-with-openssl-4.1.patch @@ -0,0 +1,23 @@ +From: fil-c-utils maintainers +Subject: [PATCH] Opt into CN name constraints with OpenSSL 4.1 + +curl still matches CN-only certificates itself. OpenSSL 4.1 no longer checks +DNS name constraints on those names unless the application explicitly enables +subject checking, allowing a constrained CA to authenticate an unrelated host. +Keep the certificate chain checks consistent with curl's hostname fallback. +This also checks CN constraints on certificates that have a SAN. + +--- a/lib/vtls/openssl.c ++++ b/lib/vtls/openssl.c +@@ -3945,2 +3945,11 @@ + * Apple's SecTrust for verification. */ ++#if OPENSSL_VERSION_NUMBER >= 0x40100000L ++ { ++ X509_VERIFY_PARAM *param = SSL_CTX_get0_param(octx->ssl_ctx); ++ /* curl's CN fallback also needs OpenSSL's DNS name constraints. */ ++ X509_VERIFY_PARAM_set_hostflags(param, ++ X509_VERIFY_PARAM_get_hostflags(param) | ++ X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT); ++ } ++#endif + SSL_CTX_set_verify(octx->ssl_ctx, SSL_VERIFY_NONE, NULL); diff --git a/curl/test-name-constraints.py b/curl/test-name-constraints.py new file mode 100644 index 0000000..25886b2 --- /dev/null +++ b/curl/test-name-constraints.py @@ -0,0 +1,148 @@ +#!/usr/bin/env python3 +"""Exercise the shipped HTTPS client's DNS name-constraint enforcement.""" +import http.server +import os +from pathlib import Path +import ssl +import subprocess +import sys +import tempfile +import threading +from urllib.parse import urlsplit + + +class Handler(http.server.BaseHTTPRequestHandler): + def handle(self): + try: + super().handle() + except (ConnectionResetError, BrokenPipeError): + # A client can abort immediately after rejecting the certificate. + pass + + def do_GET(self): + path = urlsplit(self.path).path + if path == "/repo/info/refs": + body = b"1111111111111111111111111111111111111111\trefs/heads/main\n" + elif path == "/repo/HEAD": + body = b"ref: refs/heads/main\n" + else: + body = b"fixture-ok\n" + self.send_response(200) + self.send_header("Content-Type", "text/plain") + self.send_header("Content-Length", str(len(body))) + self.end_headers() + self.wfile.write(body) + + def log_message(self, *args): + pass + + +def generate(root): + def openssl(*args): + subprocess.run(["openssl", *args], cwd=root, check=True, + stdout=subprocess.DEVNULL, stderr=subprocess.PIPE) + + def key(name): + openssl("ecparam", "-name", "prime256v1", "-genkey", "-noout", + "-out", name + ".key") + + def sign(name, cn, issuer, serial, extensions): + key(name) + openssl("req", "-new", "-key", name + ".key", "-subj", "/CN=" + cn, + "-out", name + ".csr") + (root / (name + ".ext")).write_text(extensions) + openssl("x509", "-req", "-sha256", "-days", "2", "-in", name + ".csr", + "-CA", issuer + ".pem", "-CAkey", issuer + ".key", + "-set_serial", str(serial), "-extfile", name + ".ext", + "-out", name + ".pem") + + key("root") + openssl("req", "-new", "-x509", "-sha256", "-days", "2", "-key", "root.key", + "-subj", "/CN=Fixture root", "-out", "root.pem", + "-addext", "basicConstraints=critical,CA:TRUE", + "-addext", "keyUsage=critical,keyCertSign,cRLSign") + sign("ca", "Constrained fixture CA", "root", 2, + "basicConstraints=critical,CA:TRUE,pathlen:0\n" + "keyUsage=critical,keyCertSign,cRLSign\n" + "nameConstraints=critical,permitted;DNS:allowed.test\n") + allowed = "within.allowed.test" + outside = "outside.test" + constraint_error = "permitted subtree violation" + cases = [ + ("allowed-cn", allowed, None, allowed, None), + ("allowed-san", allowed, allowed, allowed, None), + ("outside-cn", outside, None, outside, constraint_error), + ("outside-san", allowed, outside, outside, constraint_error), + ("outside-cn-with-san", outside, allowed, allowed, constraint_error), + ("san-precedence", allowed, "other.allowed.test", allowed, + "no alternative certificate subject name matches"), + ] + for serial, (name, cn, san, _, _) in enumerate(cases, start=3): + extensions = ("basicConstraints=critical,CA:FALSE\n" + "keyUsage=critical,digitalSignature\n" + "extendedKeyUsage=serverAuth\n") + if san: + extensions += "subjectAltName=DNS:" + san + "\n" + sign(name, cn, "ca", serial, extensions) + (root / (name + ".chain.pem")).write_bytes( + (root / (name + ".pem")).read_bytes() + (root / "ca.pem").read_bytes()) + return cases + + +def test(root, mode, binary, case): + name, _, _, hostname, error = case + rejected = error is not None + server = http.server.ThreadingHTTPServer(("0.0.0.0", 0), Handler) + context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) + context.load_cert_chain(root / (name + ".chain.pem"), root / (name + ".key")) + server.socket = context.wrap_socket(server.socket, server_side=True) + thread = threading.Thread(target=server.serve_forever, daemon=True) + thread.start() + port = server.server_address[1] + resolve = f"{hostname}:{port}:127.0.0.1" + url = f"https://{hostname}:{port}/" + if mode == "curl": + command = [binary, "-q", "--noproxy", "*", "--cacert", str(root / "root.pem"), + "--resolve", resolve, "--max-time", "10", "-sS", url] + expected, body = (60 if rejected else 0), "fixture-ok\n" + else: + command = [binary, "-c", "http.sslVerify=true", "-c", "http.proxy=", + "-c", "http.sslCAInfo=" + str(root / "root.pem"), + "-c", "http.curloptResolve=" + resolve, "ls-remote", url + "repo"] + expected, body = (128 if rejected else 0), "refs/heads/main" + env = {**os.environ, "HOME": str(root), "NO_PROXY": "*", + "GIT_CONFIG_NOSYSTEM": "1", "GIT_CONFIG_GLOBAL": "/dev/null", + "GIT_CONFIG_COUNT": "0", "GIT_TERMINAL_PROMPT": "0"} + env.pop("GIT_SSL_NO_VERIFY", None) + try: + result = subprocess.run(command, cwd=root, env=env, text=True, + capture_output=True, timeout=15) + if result.returncode != expected: + raise AssertionError(f"{mode} {name}: expected {expected}, got " + f"{result.returncode}\n{result.stdout}{result.stderr}") + if rejected: + assert error in result.stderr.lower(), result.stderr + assert not result.stdout, result.stdout + else: + assert body in result.stdout, result.stdout + print(f"{mode} {name}: {'rejected' if rejected else 'accepted'}", flush=True) + finally: + server.shutdown() + server.server_close() + thread.join() + + +def main(): + mode, binary = sys.argv[1:] + assert mode in ("curl", "git") + binary = str(Path(binary).resolve()) + temporary = Path.home() / "tmp" + temporary.mkdir(exist_ok=True) + with tempfile.TemporaryDirectory(prefix="name-constraints-", dir=temporary) as tmp: + root = Path(tmp) + for case in generate(root): + test(root, mode, binary, case) + + +if __name__ == "__main__": + main() diff --git a/git/Dockerfile b/git/Dockerfile index ebf2d27..f428ac4 100644 --- a/git/Dockerfile +++ b/git/Dockerfile @@ -5,15 +5,15 @@ ARG FILC_X86_64_SHA256=aab538401f78a47ab261ee79afed8c6b99e1d4848e263ae159a75b03c ARG FILC_AARCH64_SHA256=f1337799051664f93c7712141deaebe78571ae96ffcf05563d517b89440bcbc0 ARG ZLIB_VERSION=1.3.2 ARG ZLIB_SHA256=bb329a0a2cd0274d05519d61c667c062e06990d72e125ee2dfa8de64f0119d16 -ARG OPENSSL_VERSION=4.0.3 -ARG OPENSSL_SHA256=325b5c806167c13b40b1ffeadfe0248197c00eccc4cf123ec1e28d2d2fd216d9 +ARG OPENSSL_VERSION=4.1.0 +ARG OPENSSL_SHA256=50c17baf54cb008f6ce42d50deb4b28050a1aad711636cabd4b241c7e90cc2fd ARG CURL_VERSION=8.23.0 ARG CURL_SHA256=8dadd7d2536a314f982ad05a651b713f426bf7d02cc2c76cffb9796f2218e6c5 ARG PCRE2_VERSION=10.49 ARG PCRE2_SHA256=929f0b20e62879252a15886b06c89f1edef61a363cbd5826fb041080a5e557ae -ARG EXPAT_VERSION=2.9.0 -ARG EXPAT_TAG=R_2_9_0 -ARG EXPAT_SHA256=16afbb9cefead2aa278105cf27d9f597bde7fbf3dbb85015857ca7ca6a4e89ba +ARG EXPAT_VERSION=2.10.0 +ARG EXPAT_TAG=R_2_10_0 +ARG EXPAT_SHA256=5466a341f9c692ef7a958a6881311be597f8e1ce345984cf78414f54793dea4c ARG GIT_TEST_JOBS= ARG GIT_VERSION=2.56.0 ARG GIT_SHA256=26c56c296b38c0695b26fa95f475f1d01704d2d38e73465ca30b0b2f5dc789d3 @@ -60,6 +60,7 @@ RUN apt-get update \ libc6-dev \ linux-libc-dev \ make \ + openssl \ patch \ patchelf \ perl \ @@ -156,6 +157,8 @@ RUN curl -fsSL ${FETCH_RETRY} -o /tmp/curl.tar.xz \ && echo "${CURL_SHA256} /tmp/curl.tar.xz" | sha256sum -c - \ && tar --strip-components=1 -xJf /tmp/curl.tar.xz \ && rm /tmp/curl.tar.xz +COPY patches/0002-enforce-cn-name-constraints-with-openssl-4.1.patch /tmp/curl-name-constraints.patch +RUN patch --batch --forward -p1 < /tmp/curl-name-constraints.patch RUN CFLAGS="-O2 -g" LDFLAGS="-L/deps/lib" ./configure \ --disable-shared --enable-static --prefix=/deps \ --with-openssl=/deps --with-zlib=/deps \ @@ -555,6 +558,9 @@ RUN set -e; \ test -e /tmp/tls-clone/.git; \ echo "git clones over HTTPS using the system trust store" +COPY test-name-constraints.py /tests/test-name-constraints.py +RUN python3 /tests/test-name-constraints.py git /artifact/bin/git + FROM scratch AS artifact ARG FILC_VERSION diff --git a/git/patches/0002-enforce-cn-name-constraints-with-openssl-4.1.patch b/git/patches/0002-enforce-cn-name-constraints-with-openssl-4.1.patch new file mode 100644 index 0000000..ce30367 --- /dev/null +++ b/git/patches/0002-enforce-cn-name-constraints-with-openssl-4.1.patch @@ -0,0 +1,23 @@ +From: fil-c-utils maintainers +Subject: [PATCH] Opt into CN name constraints with OpenSSL 4.1 + +curl still matches CN-only certificates itself. OpenSSL 4.1 no longer checks +DNS name constraints on those names unless the application explicitly enables +subject checking, allowing a constrained CA to authenticate an unrelated host. +Keep the certificate chain checks consistent with curl's hostname fallback. +This also checks CN constraints on certificates that have a SAN. + +--- a/lib/vtls/openssl.c ++++ b/lib/vtls/openssl.c +@@ -3945,2 +3945,11 @@ + * Apple's SecTrust for verification. */ ++#if OPENSSL_VERSION_NUMBER >= 0x40100000L ++ { ++ X509_VERIFY_PARAM *param = SSL_CTX_get0_param(octx->ssl_ctx); ++ /* curl's CN fallback also needs OpenSSL's DNS name constraints. */ ++ X509_VERIFY_PARAM_set_hostflags(param, ++ X509_VERIFY_PARAM_get_hostflags(param) | ++ X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT); ++ } ++#endif + SSL_CTX_set_verify(octx->ssl_ctx, SSL_VERIFY_NONE, NULL); diff --git a/git/test-name-constraints.py b/git/test-name-constraints.py new file mode 100644 index 0000000..25886b2 --- /dev/null +++ b/git/test-name-constraints.py @@ -0,0 +1,148 @@ +#!/usr/bin/env python3 +"""Exercise the shipped HTTPS client's DNS name-constraint enforcement.""" +import http.server +import os +from pathlib import Path +import ssl +import subprocess +import sys +import tempfile +import threading +from urllib.parse import urlsplit + + +class Handler(http.server.BaseHTTPRequestHandler): + def handle(self): + try: + super().handle() + except (ConnectionResetError, BrokenPipeError): + # A client can abort immediately after rejecting the certificate. + pass + + def do_GET(self): + path = urlsplit(self.path).path + if path == "/repo/info/refs": + body = b"1111111111111111111111111111111111111111\trefs/heads/main\n" + elif path == "/repo/HEAD": + body = b"ref: refs/heads/main\n" + else: + body = b"fixture-ok\n" + self.send_response(200) + self.send_header("Content-Type", "text/plain") + self.send_header("Content-Length", str(len(body))) + self.end_headers() + self.wfile.write(body) + + def log_message(self, *args): + pass + + +def generate(root): + def openssl(*args): + subprocess.run(["openssl", *args], cwd=root, check=True, + stdout=subprocess.DEVNULL, stderr=subprocess.PIPE) + + def key(name): + openssl("ecparam", "-name", "prime256v1", "-genkey", "-noout", + "-out", name + ".key") + + def sign(name, cn, issuer, serial, extensions): + key(name) + openssl("req", "-new", "-key", name + ".key", "-subj", "/CN=" + cn, + "-out", name + ".csr") + (root / (name + ".ext")).write_text(extensions) + openssl("x509", "-req", "-sha256", "-days", "2", "-in", name + ".csr", + "-CA", issuer + ".pem", "-CAkey", issuer + ".key", + "-set_serial", str(serial), "-extfile", name + ".ext", + "-out", name + ".pem") + + key("root") + openssl("req", "-new", "-x509", "-sha256", "-days", "2", "-key", "root.key", + "-subj", "/CN=Fixture root", "-out", "root.pem", + "-addext", "basicConstraints=critical,CA:TRUE", + "-addext", "keyUsage=critical,keyCertSign,cRLSign") + sign("ca", "Constrained fixture CA", "root", 2, + "basicConstraints=critical,CA:TRUE,pathlen:0\n" + "keyUsage=critical,keyCertSign,cRLSign\n" + "nameConstraints=critical,permitted;DNS:allowed.test\n") + allowed = "within.allowed.test" + outside = "outside.test" + constraint_error = "permitted subtree violation" + cases = [ + ("allowed-cn", allowed, None, allowed, None), + ("allowed-san", allowed, allowed, allowed, None), + ("outside-cn", outside, None, outside, constraint_error), + ("outside-san", allowed, outside, outside, constraint_error), + ("outside-cn-with-san", outside, allowed, allowed, constraint_error), + ("san-precedence", allowed, "other.allowed.test", allowed, + "no alternative certificate subject name matches"), + ] + for serial, (name, cn, san, _, _) in enumerate(cases, start=3): + extensions = ("basicConstraints=critical,CA:FALSE\n" + "keyUsage=critical,digitalSignature\n" + "extendedKeyUsage=serverAuth\n") + if san: + extensions += "subjectAltName=DNS:" + san + "\n" + sign(name, cn, "ca", serial, extensions) + (root / (name + ".chain.pem")).write_bytes( + (root / (name + ".pem")).read_bytes() + (root / "ca.pem").read_bytes()) + return cases + + +def test(root, mode, binary, case): + name, _, _, hostname, error = case + rejected = error is not None + server = http.server.ThreadingHTTPServer(("0.0.0.0", 0), Handler) + context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) + context.load_cert_chain(root / (name + ".chain.pem"), root / (name + ".key")) + server.socket = context.wrap_socket(server.socket, server_side=True) + thread = threading.Thread(target=server.serve_forever, daemon=True) + thread.start() + port = server.server_address[1] + resolve = f"{hostname}:{port}:127.0.0.1" + url = f"https://{hostname}:{port}/" + if mode == "curl": + command = [binary, "-q", "--noproxy", "*", "--cacert", str(root / "root.pem"), + "--resolve", resolve, "--max-time", "10", "-sS", url] + expected, body = (60 if rejected else 0), "fixture-ok\n" + else: + command = [binary, "-c", "http.sslVerify=true", "-c", "http.proxy=", + "-c", "http.sslCAInfo=" + str(root / "root.pem"), + "-c", "http.curloptResolve=" + resolve, "ls-remote", url + "repo"] + expected, body = (128 if rejected else 0), "refs/heads/main" + env = {**os.environ, "HOME": str(root), "NO_PROXY": "*", + "GIT_CONFIG_NOSYSTEM": "1", "GIT_CONFIG_GLOBAL": "/dev/null", + "GIT_CONFIG_COUNT": "0", "GIT_TERMINAL_PROMPT": "0"} + env.pop("GIT_SSL_NO_VERIFY", None) + try: + result = subprocess.run(command, cwd=root, env=env, text=True, + capture_output=True, timeout=15) + if result.returncode != expected: + raise AssertionError(f"{mode} {name}: expected {expected}, got " + f"{result.returncode}\n{result.stdout}{result.stderr}") + if rejected: + assert error in result.stderr.lower(), result.stderr + assert not result.stdout, result.stdout + else: + assert body in result.stdout, result.stdout + print(f"{mode} {name}: {'rejected' if rejected else 'accepted'}", flush=True) + finally: + server.shutdown() + server.server_close() + thread.join() + + +def main(): + mode, binary = sys.argv[1:] + assert mode in ("curl", "git") + binary = str(Path(binary).resolve()) + temporary = Path.home() / "tmp" + temporary.mkdir(exist_ok=True) + with tempfile.TemporaryDirectory(prefix="name-constraints-", dir=temporary) as tmp: + root = Path(tmp) + for case in generate(root): + test(root, mode, binary, case) + + +if __name__ == "__main__": + main() diff --git a/nano/Dockerfile b/nano/Dockerfile index abaea6c..a6864af 100644 --- a/nano/Dockerfile +++ b/nano/Dockerfile @@ -7,8 +7,8 @@ ARG NCURSES_VERSION=6.6 ARG NCURSES_SHA256=355b4cbbed880b0381a04c46617b7656e362585d52e9cf84a67e2009b749ff11 ARG FILE_VERSION=5.48 ARG FILE_SHA256=ed14656883b23a364b4057c05595d93252da9bc473d30106519519d0da141283 -ARG NANO_VERSION=9.2 -ARG NANO_SHA256=05ecb99247b782e8a5b3a25ed4101dd034b0236902f7449bc9795b717642f7e9 +ARG NANO_VERSION=9.3 +ARG NANO_SHA256=a9affc52c9596ee0682bcdd4ceb3c0b235eb221d83d733dfd9b0dff45897cb0d FROM ubuntu:24.04 AS build @@ -143,9 +143,6 @@ RUN curl -fsSL ${FETCH_RETRY} -o /tmp/nano.tar.xz \ && tar --strip-components=1 -xJf /tmp/nano.tar.xz \ && rm /tmp/nano.tar.xz -COPY patches/0001-disable-x87-control-word-assembly-under-fil-c.patch /tmp/nano-fil-c.patch -RUN patch --batch --forward -p1 < /tmp/nano-fil-c.patch - # All of nano's features are on by default; only --enable-tiny and the # individual --disable-* flags take any away, and none are given here. The # explicit --enable-utf8 and the presence of libmagic are the two that depend diff --git a/nano/patches/0001-disable-x87-control-word-assembly-under-fil-c.patch b/nano/patches/0001-disable-x87-control-word-assembly-under-fil-c.patch deleted file mode 100644 index 50546e1..0000000 --- a/nano/patches/0001-disable-x87-control-word-assembly-under-fil-c.patch +++ /dev/null @@ -1,21 +0,0 @@ -From: fil-c-utils maintainers -Subject: [PATCH] Disable x87 control-word assembly under Fil-C - -Fil-C rejects the memory operands used by fnstcw and fldcw, leaving run-time -traps in gnulib's long-double printf paths. Fil-C's musl fenv implementation -does not expose a way to change the x87 precision control, so its default -extended precision remains in effect and the control-word save/restore is -unnecessary. - ---- a/lib/fpucw.h -+++ b/lib/fpucw.h -@@ -67,7 +67,8 @@ extern "C" { - - - /* Inline assembler like this works only with GNU C and clang. */ --#if (defined __i386__ || defined __x86_64__) && (defined __GNUC__ || defined __clang__) -+#if !defined __FILC__ \ -+ && (defined __i386__ || defined __x86_64__) && (defined __GNUC__ || defined __clang__) - - typedef unsigned short fpucw_t; /* glibc calls this fpu_control_t */ - diff --git a/openssh-server/Dockerfile b/openssh-server/Dockerfile index 1496914..9208a2e 100644 --- a/openssh-server/Dockerfile +++ b/openssh-server/Dockerfile @@ -5,8 +5,8 @@ ARG FILC_X86_64_SHA256=aab538401f78a47ab261ee79afed8c6b99e1d4848e263ae159a75b03c ARG FILC_AARCH64_SHA256=f1337799051664f93c7712141deaebe78571ae96ffcf05563d517b89440bcbc0 ARG ZLIB_VERSION=1.3.2 ARG ZLIB_SHA256=bb329a0a2cd0274d05519d61c667c062e06990d72e125ee2dfa8de64f0119d16 -ARG OPENSSL_VERSION=4.0.3 -ARG OPENSSL_SHA256=325b5c806167c13b40b1ffeadfe0248197c00eccc4cf123ec1e28d2d2fd216d9 +ARG OPENSSL_VERSION=4.1.0 +ARG OPENSSL_SHA256=50c17baf54cb008f6ce42d50deb4b28050a1aad711636cabd4b241c7e90cc2fd ARG OPENSSH_VERSION=10.6p1 ARG OPENSSH_SHA256=a9dc9565dffe8640f64d863cd29a32bc4a3dbdec0566a7fc44c5d6ee767d5f39 diff --git a/unrar/Dockerfile b/unrar/Dockerfile index 446e06f..05c1b5d 100644 --- a/unrar/Dockerfile +++ b/unrar/Dockerfile @@ -3,8 +3,8 @@ ARG FILC_VERSION=0.687 ARG FILC_X86_64_SHA256=aab538401f78a47ab261ee79afed8c6b99e1d4848e263ae159a75b03c1288da1 ARG FILC_AARCH64_SHA256=f1337799051664f93c7712141deaebe78571ae96ffcf05563d517b89440bcbc0 -ARG UNRAR_VERSION=7.3.1 -ARG UNRAR_SHA256=634900842a3737d9cc15bbcc71d4c74cc713437e0bca296a573424fe5f2660ab +ARG UNRAR_VERSION=7.3.2 +ARG UNRAR_SHA256=f61a1160d6e2ebbda2ad353c8e82f62ab4312f97fde23c6c2c982d25e0014f99 ARG RAR_FIXTURE_COMMIT=09fd4f216ef502e478f1aeb6f0e193b49056eee8 ARG RAR_FIXTURE_SHA256=4449d0e82e09f52af23a11cd84904625de8b15beafcf73e5c30dc3296beae0b2 ARG RAR_FIXTURE_ARCHIVE_SHA256=ddcc0da3ee181763a8bc42d1cab55abca2f0f994380a81435c932ab24603f430