parent:
594cab6ae95854c36078bb56c8f0f51ffc68b05e
nmyk <nick@nmyk.io>
2026-11-14T22:17:25-05:00
add oracle test against openssl compiled with no policy tree node count limit
diff --git a/scripts/openssl-unlimited.sh b/scripts/openssl-unlimited.sh
new file mode 100755
index 0000000000000000000000000000000000000000..1aa78a8398dad0b25a919217f8b4e2c42d282942
--- /dev/null
+++ b/scripts/openssl-unlimited.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+# openssl-unlimited.sh builds OpenSSL with its policy tree node limit
+# removed and prints the path of the openssl binary.
+#
+# Since CVE-2023-0464, OpenSSL refuses any policy tree over 1,000 nodes, a
+# limit that can only be changed when OpenSSL is compiled. GOVERNMENT
+# programs grow their tree roughly as depth times width, so a stock OpenSSL
+# can only check small ones. This build is for checking programs you
+# compiled yourself: without the limit, a hostile chain can make it use
+# exponential time and memory again, so never use it on untrusted input.
+#
+# The build is cached, outside the repository, in
+# ${XDG_CACHE_HOME:-~/.cache}/government/. Set OPENSSL_TAG to build
+# another release.
+#
+# Needs git, perl, make and a C compiler (on macOS, the Xcode command line
+# tools).
+set -eu
+
+tag=${OPENSSL_TAG:-openssl-4.1.0}
+cache=${XDG_CACHE_HOME:-$HOME/.cache}/government
+dir=$cache/$tag-unlimited
+bin=$dir/apps/openssl
+
+if [ ! -x "$bin" ]; then
+ echo "building $tag without its policy tree limit in $dir (a few minutes)" >&2
+ rm -rf "$dir"
+ mkdir -p "$cache"
+ git -c advice.detachedHead=false clone --quiet --depth 1 --branch "$tag" https://github.com/openssl/openssl "$dir" >&2
+ cd "$dir"
+ ./Configure -DOPENSSL_POLICY_TREE_NODES_MAX=0 no-shared no-docs no-tests >/dev/null
+ make -j"$(getconf _NPROCESSORS_ONLN)" build_programs >/dev/null
+fi
+echo "$bin"