1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-10 06:47:55 -08:00
Commit Graph

193 Commits

Author SHA1 Message Date
job
891d6bce9c Allow imposing constraints on RPKI trust anchors
The ability to constrain a RPKI Trust Anchor's effective signing
authority to a limited set of Internet Number Resources allows
Relying Parties to enjoy the potential benefits of assuming trust,
within a bounded scope.

Some examples: ARIN does not support inter-RIR IPv6 transfers, so
it wouldn't make any sense to see a ROA subordinate to ARIN's trust
anchor covering RIPE-managed IPv6 space. Conversely, it wouldn't
make sense to observe a ROA covering ARIN-managed IPv6 space under
APNIC's, LACNIC's, or RIPE's trust anchor - even if a derived trust
arc (a cryptographically valid certificate path) existed. Along these
same lines, AFRINIC doesn't support inter-RIR transfers of any kind,
and none of the RIRs have authority over private resources like
10.0.0.0/8 and 2001:db8::/32.

For more background see:
https://datatracker.ietf.org/doc/draft-snijders-constraining-rpki-trust-anchors/
https://mailman.nanog.org/pipermail/nanog/2023-September/223354.html

With and OK tb@, OK claudio@
2023-10-13 12:06:49 +00:00
tb
18c42b3002 rpki-client: Refactor sbgp_assysnum() and sbgp_addrblk()
An upcoming diff requires the ability to convert ASIdentifiers and
IpAddrBlocks into rpki-client's internal structures.  Accordingly,
split already existing code into dedicated parsing functions . The
original functions now only extract the extension-specific data from
the X509_EXTENSION.

input/ok claudio
2023-09-25 14:56:20 +00:00
tb
0636c4d090 Pass the talid to various parse functions
This will be needed by an upcoming feature where we will need to know
what trust anchor a given cert chains to. This doesn't change anything
except the size of the diff.

ok claudio job
2023-09-25 11:08:45 +00:00
job
782a58ffc8 Introduce ip_addr_range_print() to avoid code repetition
OK tb@
2023-09-25 08:48:14 +00:00
job
7cc1142d2a Ensure the X.509 Subject only contains commonName and optionally serialNumber
OK tb@
2023-09-12 09:33:30 +00:00
tb
74a82ef428 rpki-client: fix vap_pas stats
A small mistake in a diff broke the counters. Make them AFI agnostic and
adjust ometric output.

guidance & ok claudio
2023-06-29 14:33:35 +00:00
tb
c05289013d Retire log.c
Convert all cryptowarnx() and cryptoerrx() to appropriate versions of
warn() and err{,x}(). Neither users nor developers benefit from them.
If we need better errors, we need to do some thinking. libcrypto won't
do that for us.

suggested by claudio
ok job
2023-06-29 10:28:25 +00:00
job
4b5fc138be Decode and validate ASPA objects following the v1 syntax
Through draft-ietf-sidrops-aspa-profile-15, the ASPA profile was
made AFI-agnostic. This represents a simplification for both operators
and implementers in both the RPKI and BGP layers of the stack.

This update changes the JSON structure.

No effort was made to simultaneously support ASPA v0 and v1 objects.

OK tb@ claudio@
2023-06-26 18:39:53 +00:00
claudio
b268327a38 Improve detection of RRDP session desynchronization
According to RFC 8182, a given session_id and serial number represent an
immutable record of the state of the Repository Server at a certain
point in time.

Add a check to the RRDP notification file processing to compare whether
the delta hashes associated to previously seen serials are different in
newly fetched notification files. Fall back to a snapshot if a difference
is detected, because such a mutation is a strong desynchronization
indicator.

Idea from Ties de Kock (RIPE NCC).
Based on a diff by job@
With and OK job@ tb@
2023-06-23 11:36:24 +00:00
job
e1686bd76c In anticipation of a bump of the ASPA eContent profile version, update
valid_econtent_version() to allow for non-zero versions.

OK tb@
2023-06-07 10:46:34 +00:00
job
08ac1330e7 Fixup file modification timestamps to optimize failover from RRDP to RSYNC
In the RSYNC protocol a file's last modification time and its size are
used to determine whether sending a (partial) copy over the wire is needed.
Previously, when RRDP data structures are serialized to disk, the mtime of
files in DIR_VALID ended up being UTIME_NOW.

Thus, the mtimes of files obtained through RRDP will never match the mtimes
of the same files available through RSYNC - causing each and every file to
be added to the file transfer list.

Instead, use the internal timestamps of RPKI files as the last modified
timestamp. Specifically, for Signed Objects (ROAs, MFTs, GBRs, TAKs, ASPAs)
the CMS signing-time, for .cer files the X.509 notBefore, and for .crl files
the CRL lastUpdate. This results in a surprising optimization for the number
files which have to be transfered.

OK claudio@
2023-05-30 16:02:28 +00:00
claudio
0876134d17 Revert commitid ANSBO0rBvIUtTi45:
Make rpki-client choose the verification time of the time it is invoked
   rather than always getting the current system time for every certificate
   verification. This will result in output that is not variable on run-time.

Using the time of invocation does not work well with fast publishing CAs. It
can take a few minutes to reach a repo and that CA may have issued certificates
that are not yet valid if that startup time of rpki-client is used to validate.

This still keeps the -P option to specify a fixed validation time.
OK beck@ job@ tb@
2023-05-30 12:14:48 +00:00
tb
967224c858 rpki-client: use partial chains in certificate validation
The generally rather poor quality RFC 3779 code in libcrypto also performs
abysmally. Flame graphs show that nearly 20% of the parser process is spent
in addr_contains() alone. There is room for improvement in addr_contains()
itself - the containment check for prefixes could be optimized quite a bit.
We can avoid a lot of the most expensive work for certificates with tons of
resources close to the TA by using the verifier's partial chains flag.

More precisely, in the tree of already validated certs look for the first
one that has no inherited RFC 3779 resources and use that as 'trust anchor'
for our chains via the X509_V_FLAG_PARTIAL_CHAIN flag. This way we can be
sure that a leaf's delegated resources are properly covered and at the same
time significantly shorten most paths validated.

Job's and my testing indicates that this avoids 30-50% of overhead and works
equally well with LibreSSL and OpenSSL >= 1.1. The main bottlenecks in the
parser process now appear to be SHA-2 and RSA/BIGNUM, two well-known pain
points in libcrypto.

This is based on a hint by beck and was discussed extensively with beck,
claudio and job during and after m2k23.

ok claudio job
2023-05-09 10:34:32 +00:00
beck
f0813572b9 Make rpki-client choose the verification time of the time it is invoked
rather than always getting the current system time for every certificate
verification. This will result in output that is not variable on run-time.

ok tb@ claudio@
2023-04-27 08:37:53 +00:00
beck
298d2ca0f5 Add a -P option to rpki-client to specify the evaluation time
This is intended to be able to test rpki-client in a reproducable
way without worrying about the system time changing the results

ok claudio@
2023-04-26 22:05:28 +00:00
claudio
1fc2657f8f Improve accounting by tracking things by repo and tal.
This fixes some wrong accounting for repositories that are referenced
from more than one TAL. It changes the ometric lable output a little bit
since there are repository metrics that no longer include the 'name' label.
OK tb@
2023-04-26 16:32:41 +00:00
job
32c8d2fec8 Check whether products listed on a manifest were issued by the same authority as the manifest itself
OK tb@
2023-04-13 17:04:02 +00:00
claudio
d0837792d2 Add the protocol used to sync the repository to the open-metric output.
OK tb@
2023-03-30 15:29:15 +00:00
job
894936b4b8 In filemode, display the moment the signature path will expire
Previously this was only shown for ROA+ASPA. Now also show for
GBR, Geofeed, Certs, RSC, and TAK.

OK tb@
2023-03-13 19:51:49 +00:00
job
4dbb22b8de Rename some data fields to closer match their provenance
OK tb@
2023-03-13 09:24:37 +00:00
job
534b66744e Refactor expiration calculation
Unify common code paths which find the exact expiry moment into a new
helper function. Additionally, the new helper offers more accuracy by
checking more applicable CRLs whether their 'nextupdate' is 'sooner'.

tb@ noted: The helper adds a multiplier of log(#crls), but that's
certainly acceptable as it is still very cheap.

OK tb@
2023-03-12 11:54:56 +00:00
job
9f54482206 mechanical change, rename struct members to match the original X509 names
OK tb@
2023-03-10 12:44:56 +00:00
job
f5999ddfaa Show the X.509 notBefore in filemode
OK tb@
2023-03-10 12:02:11 +00:00
job
f904f2a228 In filmode also show 'Not After' for GBR records
OK tb@
2023-03-09 12:54:28 +00:00
job
1bb1e5098b Show CMS signing-time signed attribute in filemode
OK tb@
2023-03-09 09:46:21 +00:00
job
ae36eebee8 Add check for RSA key pair modulus & public exponent
Both the SPKI inside a CA's .cer TBS section and Signers wrapped in CMS
must be RSA, with mod 2048 & (e) 0x10001

OK tb@
2023-03-06 16:04:52 +00:00
claudio
acb55ac272 Add aspa-set to openbgpd config output.
Change the way the validated ASPA tree is built since OpenBGPD config
follows more the ASPA profile and puts the optional AFI to each provider
ASnum instead of duplicated everything into an IPv4 and IPv6 tree.
The JSON output of ASPA is still the same.

The inclusion of the aspa-set can currently be disabled by the -A flag.
OK tb@
2023-01-13 08:58:36 +00:00
claudio
45735add95 Validate the session_id to be a real UUID.
RFC 8182 requires the session_id to be a version 4 random UUID (using
variant 1). Now checking the version and variant is currently disabled
because there is at least one CA with a session_id that is all random
and therefor the version check triggers there.
Joint work with job@. OK job@, tb@
2023-01-04 14:22:43 +00:00
jmc
3a50f0a93a spelling fixes; from paul tagliamonte
any parts of his diff not taken are noted on tech
2022-12-28 21:30:15 +00:00
claudio
4f5f25cbf9 Rework statistic collection to be per repository and add metric output option
Many statistic values are now accounted by repository via repo_stat_inc()
At end of the run sum_stats() accumulates these stats per TAL and globally.
The new output file metrics is written when the -m output flag is specified.
The metrics file is written in OpenMetrics format (with a few tweaks to
allow node_exporter to parse the file as well). The ometric code is a copy
from bgpctl(8) and should be kept in sync.
OK tb@
2022-12-15 12:02:29 +00:00
claudio
65c1cececa Switch to struct timespec for collecting stats. This allows to use
clock_gettime(CLOCK_MONOTONIC) for runtime calculation.
OK tb@
2022-12-14 10:34:49 +00:00
claudio
fd7a2857fa Return an error string instead of surpressing the warning in valid_x509.
This way manifests can should a better error message when something fails.
With and OK tb@
2022-11-29 10:33:09 +00:00
job
ef3f6f56d6 Add support for authenticating geofeed data CSV files in filemode
RFC 9092 describes a scheme in which an authenticator is appended to a
geofeed (RFC 8805) file. It is a digest of the main body of the file
signed by the private key of the relevant RPKI certificate for a covering
address range. The authenticator is a detached CMS signature.

with and OK tb@
2022-11-26 12:02:36 +00:00
tb
087f54cd99 Move skiplist to main and merge with shortlist.
With/ok job
2022-11-18 14:38:34 +00:00
tb
7856f77c0d whitespace 2022-11-04 12:05:36 +00:00
job
2cf0e12255 Check the SIA signedObject in ROA/MFT/ASPA/TAK/GBR EE certificates
Unfortunately we can't yet error out when accessMethods other than
signedObject are encountered in the SubjectInformationAccess extension
because there is pollution in the ecosystem.

OK tb@
2022-11-04 09:43:13 +00:00
job
ee2a33daae Add support for draft-ietf-sidrops-signed-tal-12
Add support validation of Signed Objects containing Trust Anchor Keys
(TAKs - aka 'Signed TALs'). Signed TALs provide a mechanism for RIRs
to distribute and sign the next Trust Anchor with the current Trust
Anchor. This might be an improvement over visiting RIR websites and
copy+pasting TAL data by hand.

OK tb@
2022-11-02 12:43:02 +00:00
job
91176c18e4 Properly free() crl & auth tree in parser process
OK claudio@
2022-09-03 21:24:02 +00:00
job
c9e39c9516 Introduce x509_any_inherit() for objects which may not have inherit elements
Unify conformance checking of Trust Anchors, ROAs, ASPAs, RSCs - none of which
may have any 'inherit' elements in the RFC 3779 IP/AS Resources extension of
the X509 certificate.

OK tb@
2022-09-03 14:40:09 +00:00
claudio
c94cf4486d Add the repoid of the cert in the cert struct. This way it is possible
to track the parent repository id of a publication point.
Nomenclature is confusing but not much we can do here.
OK tb@ job@
2022-09-03 13:30:27 +00:00
claudio
0cda9bffbf Use the abort commands when a repo timeout happens. This is cleaner
then just failing the repo fetch but leaving the backends running.
OK tb@
2022-09-02 19:10:36 +00:00
claudio
4673c6835c Implement RRDP_ABORT, a message to abort a inflight RRDP request.
The abort is done in a way that waits for any inflight files or http
requests to finish before removing the rrdp state and before sending
the rrdp done message indicating failure.
OK tb@ and benno@
2022-09-02 18:37:17 +00:00
job
a29ddfd5ea Add support for ASPA objects (draft-ietf-sidrops-aspa-profile-10)
ASPA objects are published in the RPKI and can be used to detect and
mitigate BGP route leaks. Validated ASPA Payloads are visible through
filemode (-f) and the JSON output format (-j).

With feedback from tb@

OK claudio@ tb@
2022-08-30 18:56:49 +00:00
tb
99dbdb7f37 Check the resources in ROAs and RSCs against EE certs
The resources delegated in the RFC 3779 extensions of the EE cert for
ROAs or RSCs can be a subset of the resources in the auth chain. So far
we compared that the resources of ROAs and RSCs are covered by the auth
chain, which is not entirely correct. Extract the necessary data from
the EE cert into rpki-client's own data structures, then verify that
the EE cert's resources cover the ones claimed in the ROA or RSC.

Do this as part or ROA and RSC parsing, that the EE cert's resources are
covered by the auth chain is checked in valid_x509() later on.

All this is a bit more annoying and intrusive than it should be...

ok claudio job
2022-08-19 12:45:53 +00:00
job
8210c72b2e Remove dangling ASPA references until we land real support
OK tb@
2022-08-18 15:20:27 +00:00
job
8cae3ce1b5 Clarify and tidy up some comments
OK tb@
2022-08-17 11:57:46 +00:00
job
194059d2ff Decrease how long to wait for the remote peer to send IO before giving up
If a repository is uncommunicative, rpki-client will try other transports,
or come back later (because of a next crontab invocation).

OK claudio@
2022-08-10 10:27:03 +00:00
claudio
9170c2da45 Make the http code respect MAX_CONN_TIMEOUT and fail connects once they
hit this timeout. This is in line with the rsync code.
OK tb@ job@
2022-08-09 09:02:26 +00:00
job
2778dc2559 Unify the maximum idle IO timeout for RSYNC & HTTPS
OK claudio@
2022-08-08 15:22:31 +00:00
job
fcf9359d66 Set rsync connection timeout to 15 seconds.
OK sthen@
2022-08-08 14:10:10 +00:00