Index | Thread | Search

From:
Theo Buehler <tb@theobuehler.org>
Subject:
rpki-client: adjustments for recent ARIN changes
To:
tech@openbsd.org
Date:
Tue, 25 Aug 2026 11:08:23 +0200

Download raw body.

Thread
  • Theo Buehler:

    rpki-client: adjustments for recent ARIN changes

Last week, ARIN finally reencoded their old ROAs. Unfortunately this
doesn't really allow us to simplify anything... Quite the contrary.

We don't really have a way to make the templated ASN.1 parser stricter,
so it will continue to accept some non-DER BER constructs like indefinite
length encoding and octet strings split into multiple chunks and other
garbage. If we want to fix this we will have to do our own DER parsing.

Thus, the cms.c bit simply detects the length encoding used by these
malformed ROAs, nothing else. The filemode dance is for rpki-client -f
to continue to work on these files.

Frankly, I'm not sure this cms.c bit buys us much, but it is the only
non-complicated thing I can think of.


In the TBS sigalg parser, we can drop the verbose > 1 bit since we no
longer have >1k things about which we whine. In fact, none are left.

Dropping this verbose > 1 seems a no-brainer but of course it also
doesn't help anything, really.

This comes from an old mistake made around the turn of the millenia
biting us in the RPKI until last week...  See this comment in
x509_check_tbs_sigalg():

   Correct encoding of parameters is explicit ASN.1 NULL
   (V_ASN1_NULL), but implementations MUST accept absent
   parameters due to an ASN.1 syntax translation mishap,
   see, e.g., RFC 4055, 2.1.

We *could* consider de-Postelizing this and turn this warning into an
error (again, return 0 probably only in !filemode), deliberately
deviating from an RFC 4055 MUST.

What do others think?

Index: cms.c
===================================================================
RCS file: /cvs/src/usr.sbin/rpki-client/cms.c,v
diff -u -p -r1.60 cms.c
--- cms.c	24 Jan 2026 08:11:26 -0000	1.60
+++ cms.c	20 Aug 2026 19:18:12 -0000
@@ -26,6 +26,8 @@
 
 #include "extern.h"
 
+extern int filemode;
+
 static int
 cms_extract_econtent(const char *fn, CMS_ContentInfo *cms, unsigned char **res,
     size_t *rsz)
@@ -179,7 +181,7 @@ cms_parse_validate_internal(struct cert 
 	char				 buf[128], obuf[128];
 	const ASN1_OBJECT		*obj, *octype;
 	ASN1_OCTET_STRING		*kid = NULL;
-	CMS_ContentInfo			*cms;
+	CMS_ContentInfo			*cms = NULL;
 	long				 version;
 	STACK_OF(X509)			*certs = NULL;
 	STACK_OF(X509_CRL)		*crls = NULL;
@@ -198,6 +200,17 @@ cms_parse_validate_internal(struct cert 
 	/* just fail for empty buffers, the warning was printed elsewhere */
 	if (der == NULL)
 		return 0;
+
+	if (len < 2) {
+		warnx("%s: RFC 6488: CMS encoding too short", fn);
+		goto out;
+	}
+	if (der[0] == 0x30 && der[1] == 0x80) {
+		warnx("%s: RFC 6488: indefinite length encoding disallowed "
+		    "in DER", fn);
+		if (!filemode)
+			goto out;
+	}
 
 	oder = der;
 	if ((cms = d2i_CMS_ContentInfo(NULL, &der, len)) == NULL) {
Index: x509.c
===================================================================
RCS file: /cvs/src/usr.sbin/rpki-client/x509.c,v
diff -u -p -r1.133 x509.c
--- x509.c	21 Jun 2026 19:23:56 -0000	1.133
+++ x509.c	20 Aug 2026 17:09:44 -0000
@@ -585,11 +585,7 @@ x509_check_tbs_sigalg(const char *fn, co
 			    fn, LN_sha256WithRSAEncryption);
 			return 0;
 		}
-		/*
-		 * As of July 2025, there still are ~1600 ROA EE certs with this
-		 * faulty encoding, all issued by ARIN before September 2020.
-		 */
-		if (verbose > 1 && ptype == V_ASN1_UNDEF)
+		if (ptype == V_ASN1_UNDEF)
 			warnx("%s: RFC 4055, 5: %s without ASN.1 parameters",
 			    fn, LN_sha256WithRSAEncryption);
 		return 1;