parent:
cd714ebecbf3d298a78692baf2a78725293b3ff2
nmyk <nick@nmyk.io>
2026-11-14T22:23:03-05:00
update design doc, makefile, openssl test
diff --git a/DESIGN.md b/DESIGN.md
index 0e083e89beaa9af7dd1e2c775da68a587412bd99..3bbe3a51bde3f5e667b687588c2f72c19833f377 100644
--- a/DESIGN.md
+++ b/DESIGN.md
@@ -103,7 +103,7 @@ **Strict check.** Plain RFC processing forgives mistakes by deleting code. After policy processing, the interpreter also verifies that certs 2..n assert `anyPolicy` and cert 1 does not, that every explicitly asserted policy in cert *i* is a node at depth *i*, that every mapping in cert *i* produced an edge, and that the program's distinct node ids are exactly 1..N with no gaps. A failure is a ratification error naming the orphaned OID. This turns silent data loss into a compile-style error.
**Denial-of-service guard.** Policy processing has caused real DoS bugs, e.g. Go's CVE-2026-32281 (inefficient policy validation, fixed in Go 1.25.9 / 1.26.2). The graph form keeps work linear in mappings, and the interpreter caps nodes (`--max-nodes`, default 1,000,000), checking the cap as each node is made rather than after. A cap on nodes is not a cap on time, so each cert's work is also kept linear in its level: parents are indexed by the policies they expect, nodes by policy for mappings, and pruning stops at the first level where nothing died. The worst case the cap allows is cheap to reach: every atom above the bottom is copied down once per cert, so a 400 KB file with 6,000 top-level atoms beside one 200-deep form asks for 1.2 million nodes. It is refused in under two seconds.
-**OpenSSL.** OpenSSL is not a full validator for GOVERNMENT. Since CVE-2023-0464 it refuses any policy tree over 1,000 nodes (`OPENSSL_POLICY_TREE_NODES_MAX`, fixed when OpenSSL is built), reporting it as a failed allocation in its policy check. It still builds RFC 5280's tree, which unfolds shared nodes, and every atom above the bottom is copied down once per cert, so a program's tree grows roughly as depth times width: a 31-deep `(+ 1 (+ 1 ...))` fits in 961 nodes, a 32-deep one needs 1,024, and six levels of shared doubling that are a few dozen graph nodes unfold past the limit. Every test program and example fits. Past the limit, a program is still lawful to GOVERNMENT, whose graph budget is a million nodes; OpenSSL just cannot check it.
+**OpenSSL.** OpenSSL is not a full validator for GOVERNMENT. Since CVE-2023-0464 it refuses any policy tree over 1,000 nodes (`OPENSSL_POLICY_TREE_NODES_MAX`, fixed when OpenSSL is built), reporting it as a failed allocation in its policy check. It still builds RFC 5280's tree, which unfolds shared nodes, and every atom above the bottom is copied down once per cert, so a program's tree grows roughly as depth times width: a 31-deep `(+ 1 (+ 1 ...))` fits in 961 nodes, a 32-deep one needs 1,024, and six levels of shared doubling that are a few dozen graph nodes unfold past the limit. Even a flat `(+ 1 … 1000)` needs 1,002. Every test program and example fits. Past the limit, a program is still lawful to GOVERNMENT, whose graph budget is a million nodes; a stock OpenSSL just cannot check it. The limit holds through OpenSSL 4.1.0, and can only be changed when OpenSSL is built: `make oracle` builds one with `-DOPENSSL_POLICY_TREE_NODES_MAX=0` (`scripts/openssl-unlimited.sh`, cached outside the repository) and runs the oracle tests with it, and that build agrees with GOVERNMENT on every program over the limit too. Without the limit OpenSSL is open to CVE-2023-0464 again, so that build is only for checking programs you compiled yourself.
## OID encoding
@@ -411,7 +411,7 @@ | Round trip | Go test over every `testdata` file | `gov2lisp(lisp2gov(src))` equals the normalized source, comments included |
| Ratification | Go table test that mutates a valid chain | Flipped signature byte, reordered certs, dropped mapping, orphaned policy, mapping in cert n, `anyPolicy` missing from a cert 2..n or asserted in cert 1, a list node with no elements, unknown critical extension; each expects a specific error |
| Civic | Go table test | Runs before, inside and after a `--not-before`/`--not-after` window; repeal of each depth; scheduled repeal; stale CRL; CRL signed by the wrong key; `--anchor` pin across a re-ratified version; notes over 200 characters; default-key warning |
| Golden | `lisp2gov/testdata/golden.gov` and `golden.crl`, from `golden.gov.lisp` | Byte equality with every option fixed (seed, author, dates), so any change to the encoding fails, reported as the block and DER byte where it starts; the program uses every literal kind, a split note, a dotted pair and a shared node, and must also run. `go test ./lisp2gov -update` accepts a deliberate change |
-| External oracle (optional) | `lisp2gov/openssl_test.go`: `openssl verify -x509_strict -policy_check -explicit_policy -policy 2.5.29.32.0 -policy_print`, plus `-crl_check_all` with repeal CRLs | OpenSSL accepts every test program and example, shared and not, and reports the same top-level policies; it refuses each broken program (tampered, missing depth, foreign anchor, out of force) and each repealed one. Three known disagreements are pinned: scheduled repeals, a list issued after the check time, and OpenSSL's 1,000-node tree limit (see OpenSSL below). Skipped without OpenSSL; `$GOVERNMENT_OPENSSL` picks the binary, since macOS's `openssl` is LibreSSL. Without `-policy 2.5.29.32.0` OpenSSL treats the acceptable set as empty |
+| External oracle (optional) | `lisp2gov/openssl_test.go`: `openssl verify -x509_strict -policy_check -explicit_policy -policy 2.5.29.32.0 -policy_print`, plus `-crl_check_all` with repeal CRLs | OpenSSL accepts every test program and example, shared and not, and reports the same top-level policies; it refuses each broken program (tampered, missing depth, foreign anchor, out of force) and each repealed one. Three known disagreements are pinned: scheduled repeals, a list issued after the check time, and OpenSSL's 1,000-node tree limit (see OpenSSL below). Skipped without OpenSSL; `$GOVERNMENT_OPENSSL` picks the binary, since macOS's `openssl` is LibreSSL. `make oracle` runs them with an OpenSSL built without its tree limit. Without `-policy 2.5.29.32.0` OpenSSL treats the acceptable set as empty |
Ratification tests are Go rather than Lisp because a Lisp source cannot express a broken certificate.
diff --git a/Makefile b/Makefile
index 1fa724fccf5a995a0c6b874a4167b1300e1c8b38..845c97ba8c9b5cb0733bf5a9a4bbcff36440d2d5 100644
--- a/Makefile
+++ b/Makefile
@@ -21,4 +21,11 @@ install:
go install ./cmd/...
clean:
- rm -rf bin
\ No newline at end of file
+ rm -rf bin
+
+# Check compiled programs against OpenSSL with its 1,000-node policy tree
+# limit removed, building that OpenSSL the first time (see
+# scripts/openssl-unlimited.sh). The ordinary tests use whatever openssl is
+# installed, limit and all.
+oracle:
+ @bin=$$(scripts/openssl-unlimited.sh) && GOVERNMENT_OPENSSL=$$bin go test ./lisp2gov -run OpenSSL -count=1 -v
\ No newline at end of file
diff --git a/lisp2gov/openssl_test.go b/lisp2gov/openssl_test.go
index 8b0bbca97024deac1e8cbffdb6e70ee94cfedf8d..03e8c2022c503d6491714f9b882871d9c2d063f9 100644
--- a/lisp2gov/openssl_test.go
+++ b/lisp2gov/openssl_test.go
@@ -321,7 +321,8 @@ // GOVERNMENT's graph holds a million. Past the limit OpenSSL is no oracle.
//
// Under the limit OpenSSL must accept. Over it, it may refuse, but only
// for the size of its tree; a build without the limit accepts, and the
-// test logs that.
+// test logs that. make oracle builds such an OpenSSL and runs these tests
+// with it, which makes OpenSSL a full oracle for these programs too.
func TestOpenSSLTreeLimit(t *testing.T) {
needOpenSSL(t)
doubling := func(k int) string {
@@ -342,6 +343,7 @@ }{
{"31 deep, 961 nodes", deep(31), true},
{"32 deep, 1,024 nodes", deep(32), false},
{"200 deep", deep(200), false},
+ {"1,000 arguments, 1,002 nodes", "(+" + strings.Repeat(" 1", 1000) + ")", false},
{"4 levels of shared doubling", doubling(4), true},
{"6 levels of shared doubling, small as a graph", doubling(6), false},
}