Category: Security

  • Certificate pinning, Certificate Transparency and what to do when a CA misissues

    Certificate pinning, Certificate Transparency and what to do when a CA misissues

    The flaw everyone knows about

    Any CA in your browser's or operating system's trust store can issue a valid certificate for any domain. Not just the domains it has customers for. All of them. The web PKI is only as strong as the weakest of a few hundred organizations, and some of them have been breached.

    The 2011 DigiNotar compromise is the textbook case. Attackers got fraudulent certificates issued, including one for *.google.com, and used them against users in Iran. The reports I've read put the number of rogue certificates at roughly 500. Chrome flagged it because Google had pinned its own properties in the browser, and a user hit the warning and posted about it. Detection came from a hardcoded list, not from anything in the protocol.

    Two mechanisms came out of that era to deal with it: pinning, which limits which keys a client will accept, and Certificate Transparency, which makes every issuance publicly visible. They solve different halves of the problem, and the web ended up keeping one and mostly abandoning the other.

    Pinning: sharp, and aimed at your own foot

    HTTP Public Key Pinning (RFC 7469, 2015) let a site send a header telling browsers which public keys to trust for it. The failure modes were ugly. Pin the wrong key, or lose the one you pinned, and your site is unreachable for every returning visitor until max-age runs out. An attacker who briefly controlled your server could pin a key of their own and hold you hostage. Chrome removed HPKP support in version 67 in 2018 and nobody missed it.

    Pinning still makes sense in one place: clients you ship yourself, talking to servers you run. A mobile app or an internal service-to-service client. Pin the hash of the SubjectPublicKeyInfo, not the leaf certificate, so renewals that keep the key don't break you. Always include a backup pin for a key you haven't deployed yet.

    openssl s_client -connect example.com:443 -servername example.com </dev/null 2>/dev/null \
      | openssl x509 -pubkey -noout \
      | openssl pkey -pubin -outform der \
      | openssl dgst -sha256 -binary | base64

    On Android, Network Security Config takes that value directly, and the expiration attribute is the part people skip and then regret:

    <network-security-config>
      <domain-config>
        <domain includeSubdomains="true">api.example.com</domain>
        <pin-set expiration="2027-06-01">
          <pin digest="SHA-256">PRIMARY_KEY_HASH_BASE64=</pin>
          <pin digest="SHA-256">BACKUP_KEY_HASH_BASE64=</pin>
        </pin-set>
      </domain-config>
    </network-security-config>

    My honest opinion: if you can't force an app update quickly, don't pin a public CA's key. A bad pin on phones is an outage you can't roll back, because the fix has to go through app review and then through users actually updating. If you do pin, pin to a private CA you control, or to an intermediate with a backup, and treat the pin-set as something with an owner and a calendar entry. Also keep in mind that pinning is a speed bump on a device the user controls. Anyone with a rooted phone and Frida will get past it in minutes. It stops network attackers, not the person holding the handset.

    Certificate Transparency: detection, not prevention

    CT (RFC 6962, 2013) takes the opposite approach. CAs submit every certificate to public, append-only logs built on Merkle trees, and get back a signed certificate timestamp (SCT) that gets embedded in the certificate. Chrome began requiring SCTs for newly issued publicly trusted certificates in April 2018, and Apple followed later that year. A certificate with no SCT doesn't validate in those browsers.

    CT does not stop a CA from issuing a bad certificate. The rogue certificate still validates. What changed is that it can no longer be issued quietly, because a log entry has to exist for it to work. That only helps if somebody is reading the logs. For your own domains, that somebody is you.

    The quick version uses crt.sh:

    curl -s 'https://crt.sh/?q=example.com&output=json' \
      | jq -r '.[] | select(.issuer_name | test("Let.s Encrypt") | not)
               | [.id, .not_before, .issuer_name, .name_value] | @tsv'

    That prints every logged certificate for the name that wasn't issued by the CA you expect. It's fine for a spot check. crt.sh is a free service that times out regularly, so for a real alert use a monitor that tails the logs, such as Cert Spotter or certstream, and send hits somewhere a human reads.

    One cost to know about: precertificates put every hostname in the public logs. If your internal service names are sensitive, issuing publicly trusted certificates for them tells the world they exist. Use a wildcard or run a private CA for the internal names. Staging hostnames with project codenames in them are a common thing to find in a log search.

    Make the expected issuer a written fact

    Monitoring only works if "unexpected" is defined. Keep a short list of which CAs are allowed to issue for each domain, and publish it as DNS CAA records (RFC 8659). CAs must check CAA before issuing. RFC 8657 adds an accounturi parameter that restricts issuance to your specific ACME account, which is much tighter than naming the CA.

    example.com. IN CAA 0 issue "letsencrypt.org; accounturi=https://acme-v02.api.letsencrypt.org/acme/acct/1234567"
    example.com. IN CAA 0 iodef "mailto:[email protected]"

    CAA is a control on honest CAs. A compromised or malicious CA ignores it. So CAA reduces mistakes, and CT monitoring catches whatever gets past it. You want both.

    When a certificate shows up that you didn't request

    I'd run it in this order.

    First, rule out yourself. Check your ACME account history, your cloud load balancer certificates and your CDN, because the most common unexpected certificate is one that a colleague or a vendor requested. Most alerts end here.

    If it's really not yours, report it to the issuing CA with the log entry ID and ask for revocation. The CA/Browser Forum Baseline Requirements set revocation deadlines of 24 hours or five days depending on the reason, and a certificate issued without the domain holder's authorization is a clear case. Meanwhile, treat the domain as under attack: check DNS records and registrar access, since the usual route to a bad certificate is a hijacked validation path and not a rogue CA.

    Revocation itself is weak. Browsers don't reliably check OCSP or CRLs on every connection. Chrome relies on its CRLSets and Firefox on CRLite, and both cover only part of the picture. A revoked certificate can stay usable against some clients for a while, so don't assume revocation ends the exposure.

    For a CA that misissues repeatedly, the real enforcement is the root programs. File an incident report with Mozilla's CA program or send the details to Chrome's root program. That path has teeth: Chrome distrusted Symantec's PKI in stages across 2018, and distrusted new Entrust certificates issued after November 11, 2024.

    Shorter lifetimes help more than any of this

    The cleanest mitigation is a smaller window. The CA/Browser Forum's ballot SC-081v3, approved in 2025, steps maximum certificate lifetime down to 200 days from March 2026, 100 days from March 2027 and 47 days from March 2029. A misissued certificate that expires in 47 days is a smaller problem than one that lasts a year, and automation that renews that often will also notice when something changes.

    If I had one afternoon for this, I wouldn't spend it on pinning. I'd write the CAA records with account URIs, set up a CT monitor that pages on any issuer I didn't list, and write down who to call at each CA. Pinning can come later, and only for clients I can update.

  • Kerberoasting and AS-REP roasting: how service tickets get cracked offline, and what actually stops it

    Kerberoasting and AS-REP roasting: how service tickets get cracked offline, and what actually stops it

    The attack lives mostly outside your logs

    Flow diagram: an attacker with any domain user requests service tickets from the domain controller, carries them offline for cracking, with detection points and a bar comparison of RC4, AES256 and gMSA guessing speed

    The diagram shows where Kerberoasting is visible to defenders and why the encryption type changes the cost of guessing.

    Most Active Directory attacks that matter share one trait: the noisy part happens on the attacker’s own hardware. Kerberoasting is the cleanest example. Tim Medin presented it in 2014, and it still works in 2026 on a depressing share of the domains I get to look at, because it needs nothing but an ordinary domain account.

    Here is the mechanism. Any authenticated user can ask a domain controller for a service ticket (a TGS) for any account that has a service principal name (SPN) registered. The KDC doesn’t check whether you’re allowed to use the service. Authorization is the service’s job. Part of that ticket is encrypted with a key derived from the service account’s password. So the attacker requests tickets for every SPN-bearing account, carries them away, and guesses passwords against them at GPU speed. No lockouts, no failed logons, no traffic to the target service.

    If the service account password is “Summer2019!” the game is over in seconds. If it’s 25 random characters, the game is also over, but in the defender’s favor.

    Why the encryption type decides everything

    The ticket is encrypted with whatever the account supports. For RC4 (etype 23), the key is the account’s NT hash, which is an unsalted MD4 of the password. Cracking it means computing MD4 and a couple of HMAC-MD5 rounds per guess. That is very fast on a GPU. Public hashcat benchmarks put a single modern card in the billions of guesses per second for this mode (hashcat mode 13100).

    For AES256 (etype 18, RFC 3962), the key comes from PBKDF2 with 4096 iterations and a salt built from the realm and principal name. Each guess costs thousands of HMAC computations, and the salt kills precomputed tables. Hashcat handles these too (modes 19600 for etype 17 and 19700 for etype 18), and the speed difference against RC4 is orders of magnitude. I won’t quote an exact ratio because it varies by card and by version.

    The attacker picks the encryption type in the request, and the KDC will usually go along with RC4 if the account allows it. That is why “AES only” on service accounts matters more than most password policy tweaks. It turns a weak password from an instant loss into a slow one, and a strong password from a hard problem into a practically impossible one.

    AS-REP roasting is the same idea, one step earlier

    Kerberos pre-authentication makes a client prove it knows the password before the KDC hands anything back. If an account has the “Do not require Kerberos preauthentication” flag (DONT_REQ_PREAUTH), anyone on the network can send an AS-REQ for that user and get back an AS-REP, part of which is encrypted with the user’s key. No domain credentials are needed at all, which is the difference from Kerberoasting. Hashcat mode 18200 covers the RC4 flavor.

    I’ve never found a legitimate modern reason for this flag. It exists for ancient Kerberos clients and for the occasional “temporary” fix that nobody reverted. Finding it is trivial:

    Get-ADUser -Filter 'DoesNotRequirePreAuth -eq $true' -Properties DoesNotRequirePreAuth |
      Select-Object SamAccountName, Enabled

    Clear the flag, and if something breaks, fix the something.

    Finding your exposure

    Start by listing which user accounts carry SPNs and what encryption they advertise. Computer accounts have random 120-character passwords that rotate, so ignore them. User accounts are the problem.

    Get-ADUser -Filter 'ServicePrincipalName -like "*"' `
      -Properties ServicePrincipalName, PasswordLastSet, 'msDS-SupportedEncryptionTypes' |
      Select-Object SamAccountName, PasswordLastSet,
        @{n='EncTypes';e={$_.'msDS-SupportedEncryptionTypes'}},
        @{n='SPNs';e={$_.ServicePrincipalName -join ';'}}

    An empty or zero `msDS-SupportedEncryptionTypes` means the domain default applies, and for years that default allowed RC4. Microsoft has been tightening the KDC defaults away from RC4 over several rounds of updates, so check your own domain controllers’ behavior instead of assuming. Sort by `PasswordLastSet`. A service account whose password predates the person who currently runs the service is the first one I’d fix.

    The fixes, in the order I’d do them

    First, move service accounts to group managed service accounts (gMSA) wherever the software supports it. The domain generates a long random password and rotates it on a schedule (30 days by default), and nobody ever types it. Kerberoasting a gMSA gets the attacker a ticket they will never crack. Plenty of older software can’t use gMSAs, which is the whole reason the other fixes exist.

    Second, for accounts that must stay as ordinary users, set a long random password. Twenty-five characters from a password manager is fine. Length matters more than complexity rules here, because the attacker is guessing offline against the hash.

    Third, restrict the account to AES:

    Set-ADUser svc_sql -KerberosEncryptionType AES128,AES256

    Test this on a non-production service first. A service host or an old client that only speaks RC4 will start failing, and you want to learn that in a maintenance window. Also, changing the supported types doesn’t change the stored keys until the password is next changed, so reset the password after setting the flag.

    Fourth, strip privileges. A Kerberoastable account in Domain Admins is a disaster waiting for a lazy password. I’ve seen SQL service accounts with domain admin rights because someone once needed to get an install working. Cracking that one ticket is the whole engagement.

    Detection that has a decent signal-to-noise ratio

    Event ID 4769 (a Kerberos service ticket was requested) fires constantly in a normal domain, so alerting on it raw is useless. What works is filtering on shape.

    Ticket Encryption Type 0x17 (RC4) against a user-account SPN, in a domain where almost nothing should still negotiate RC4, is a strong signal. A single account requesting tickets for many different SPNs in a short window is the other. Roasting tools usually enumerate every SPN in one pass, so a burst of 4769 events from one client for dozens of services stands out against a baseline of one or two.

    For AS-REP roasting, look at event 4768 with Pre-Authentication Type 0 for any account. After you’ve cleared the flag, any hit is an attempt against an account that shouldn’t exist.

    My favorite control is cheap. Create a decoy user with an SPN that looks juicy (something like `MSSQLSvc/backup-sql01`), give it a 30-character random password and no real privileges, and alert on any ticket request for it. Nobody has a legitimate reason to request that ticket, so there’s no baseline to tune. The only caveat is that it catches the attacker who roasts everything, not the one who picks a single target.

    What this doesn’t solve

    Everything above makes cracking harder or noisier. None of it stops the ticket request, because the KDC is behaving as designed. If a domain account can be phished or purchased, the attacker gets to try. So pair it with controls on the first foothold: phishing-resistant MFA, tiering so service accounts can’t log on interactively to workstations, and limited blast radius for every account that holds an SPN.

    I’d also be wary of any assessment that reports Kerberoasting as “found 40 roastable accounts” as the finding. The useful measure is how many of those would fall to a 10-billion-guess wordlist attack and what each one can reach. A roastable account with a 25-character password and no privileges is mostly a note. A roastable account with a seven-year-old password in a privileged group is an incident you haven’t had yet.