ms-icpr
STATUS: 0.1.0-dev — pre-alpha, offline skeleton.
MS-ICPR / MS-WCCE client for AD-CS enrollment, with an ESC1 CSR
SubjectAltName{otherName, userPrincipalName} injection primitive.
Purpose
Submit certificate requests to an Enterprise CA over RPC and retrieve the
issued cert. The offensive path exercised here is ESC1: against an
ENROLLEE_SUPPLIES_SUBJECT template, a low-privileged user can request a
client-auth certificate bound to any UPN in the domain (e.g.
administrator@corp.local) and then Kerberos-authenticate as that user via
PKINIT.
Consumes ms-crtd::CertTemplate for template-shape pre-flight so submitting
against an obviously-non-abusable template fails locally.
What works today
build_csr_with_upn_san(subject, upn, key_pem) -> Vec<u8>— produces a valid PKCS#10 CSR signed with SHA256-RSA, carrying a SubjectAltName otherName(UPN) extension. Deterministic, offline, round-trip-testable.parse_rsa_private_key_pem— accepts both PKCS#8 and PKCS#1 PEM.IcprClient::submit_request— offline pre-flight checks (schema_version >= 1,min_ra_signatures <= 0, CSR is DER SEQUENCE) then dispatches through anIcprTransport. The bundledStubTransportreturnsError::LiveDcOnly.
What is stubbed
- NDR marshalling of
CertServerRequest[in]/[out] parameters — needs live-DC iteration for pointee ordering. Seedcerpc::icprin the workspace (READ-ONLY reference). - SMB
\PIPE\cert/ DCOMncacn_ip_tcpsealed-bind wiring. - Certificate-response parsing (CERTTRANSBLOB → PEM).
Minimal usage
use ;
let csr = build_csr_with_upn_san?;
let mut client = stub;
match client.submit_request
# Ok::
Layout
src/
lib.rs # public re-exports
der.rs # hand-rolled minimal DER encoder + tiny reader
oids.rs # well-known OIDs
csr.rs # PKCS#10 builder — the ESC1 primitive
rpc.rs # IcprClient + IcprTransport trait + StubTransport
error.rs # thiserror Error enum
tests/
csr.rs # CSR shape + signature-algo + input-validation
rpc.rs # pre-flight + stub-transport LiveDcOnly path
Known gaps
- Only single-RDN subjects (
CN=<subject>) are emitted. - Only RSA keys. ECDSA support means adding a second signing branch and
emitting
SubjectPublicKeyInfoforid-ecPublicKey. subject_alt_name_upn_extemits exactly one otherName. Multi-SAN requires aVec<GeneralName>builder.- No DER re-parser check inside
build_csr_with_upn_san— callers who want strict validation can round-trip throughx509-cert.
Dependencies
Deliberately narrow: rsa, sha2, x509-cert (structural round-trip
only), thiserror, plus the workspace crates dcerpc, ms-ndr, ms-crtd.
Zero serde_json, zero macro-heavy frameworks. The DER encoder is
hand-rolled (~200 LOC) — same posture as hashglass.
License
MIT.