|
| 1 | +# Security Model |
| 2 | + |
| 3 | +First off, this application is likely not secure. It hasn't been |
| 4 | +audit, fuzz tested, or even really tested at all. That means |
| 5 | +there's very likely a critical bug that breaks its model. |
| 6 | + |
| 7 | +This page aims to describe the **theoretical** security of the |
| 8 | +app, with that in mind. It focuses on cases where this authenticator |
| 9 | +deviates from what you might expect from the CTAP2 standard. |
| 10 | + |
| 11 | +## Principle: PINs Matter |
| 12 | + |
| 13 | +The core principle of a FIDO2 device is to be one of two factors. |
| 14 | +The authenticator represents "something you have". The PIN represents |
| 15 | +"something you know". |
| 16 | + |
| 17 | +Gaining complete access to the authenticator should not be useful for |
| 18 | +an attacker unless they know your PIN. |
| 19 | + |
| 20 | +Traditional implementations of FIDO2 devices do this by storing the |
| 21 | +PIN on the device "securely", and then relying on the correctness |
| 22 | +of their software and the tamper-proofness of their hardware to |
| 23 | +protect private keying material. |
| 24 | + |
| 25 | +This app is different. In this app, once you set a PIN, the "wrapping |
| 26 | +key" - without which the authenticator is useless - is encrypted using |
| 27 | +a key derived from the PIN. This means no credentials can be created |
| 28 | +or used unless you provide your PIN... |
| 29 | + |
| 30 | +## Details: Security Levels |
| 31 | + |
| 32 | +On boot, the device generates an AES256 key, the "wrapping key". |
| 33 | + |
| 34 | +Each individual credential issued by the app is a SecP256r1 keypoint, |
| 35 | +generated randomly on-device for that credential. The private key |
| 36 | +is then AES256-CBC encrypted along with the RP ID, using a random |
| 37 | +IV, and the result is used as the "credential ID". |
| 38 | + |
| 39 | +This means relying parties are holding their own encrypted private |
| 40 | +keys. The keypair itself provides approximately 128 bits of |
| 41 | +brute-force resistance. The wrapping key provides a strong 256 bits. |
| 42 | + |
| 43 | +The wrapping key is - when a PIN is set - encrypted using a "PIN key" |
| 44 | +produced by running five (by default) rounds of PBKDF2 over the first |
| 45 | +sixteen bytes of a SHA-256 of the user's PIN, with a 28-byte random |
| 46 | +salt. This means that "unwrapping" the wrapping key, were an attacker |
| 47 | +to gain access to it, would require a targeted attack whose brute-force |
| 48 | +difficulty is at most 128 bits, and is likely set by the entropy of |
| 49 | +the user's PIN. |
| 50 | + |
| 51 | +**Use a strong PIN** if you care about security in the event your |
| 52 | +device is entirely compromised. Despite the name, there is no |
| 53 | +requirement that PINs be numeric. You can use any sequence of |
| 54 | +characters up to 64 bytes long. |
| 55 | + |
| 56 | +### hmac-secret keys |
| 57 | + |
| 58 | +The hmac-secret extension keys are made by performing an HMAC-SHA256 |
| 59 | +of a particular credential's ECDSA private key, using a unique |
| 60 | +32-byte key. This makes the brute-force resistance of these keys |
| 61 | +dependent on the entropy in a raw ECDSA private key, which is |
| 62 | +somewhat less than 256 bits and likely considerably stronger |
| 63 | +than the ECDSA keypair itself. |
| 64 | + |
| 65 | +## Threat Modeling |
| 66 | + |
| 67 | +### An attacker has my device and knows my PIN |
| 68 | + |
| 69 | +The attacker is you. Do better next time. |
| 70 | + |
| 71 | +### An attacker can intercept traffic to and from my authenticator |
| 72 | + |
| 73 | +Yeah, that's how NFC works. |
| 74 | + |
| 75 | +The important parts of the traffic are encrypted and authenticated |
| 76 | +with ECDH. The attacker cannot reasonably "see" your PIN. They can |
| 77 | +see incidental data like credential IDs being newly created, but |
| 78 | +the security impact is minimal. |
| 79 | + |
| 80 | +If they can forge traffic to the authenticator, they could hard-reset it, |
| 81 | +wiping your keys. |
| 82 | + |
| 83 | +### An attacker has malware on the machine I'm using with my authenticator |
| 84 | + |
| 85 | +- The attacker could reset the authenticator, deleting your keys |
| 86 | +- They could keylog your PIN, removing its additional security, but |
| 87 | + only when you provide it on the compromised machine |
| 88 | +- They could attempt to guess your PIN, but they only get eight tries |
| 89 | +- If they DO get your PIN, they can use the authenticator as you |
| 90 | + for the duration it's connected to the compromised machine |
| 91 | +- If you haven't set a PIN, that's the same as them knowing your PIN |
| 92 | + for this threat model |
| 93 | + |
| 94 | +### An attacker has physical acccess to my smartcard, and I didn't set a PIN |
| 95 | + |
| 96 | +The attacker has fully compromised your security and can use the |
| 97 | +authenticator to pretend to be you in any way it is able. |
| 98 | + |
| 99 | +Resident keys stored on the device will let the attacker see your |
| 100 | +user IDs on different web sites, etc. They can use those to log |
| 101 | +in to those sites. |
| 102 | + |
| 103 | +Non-resident keys are slightly better: the attacker has to guess |
| 104 | +which service you'd registered with, and your username. |
| 105 | + |
| 106 | +### An attacker has physical access to my smartcard, but I set a PIN |
| 107 | + |
| 108 | +If the smartcard itself is physically secure, this is the same as |
| 109 | +the "malware" case above. **If not**, then we are in an interesting |
| 110 | +situation. |
| 111 | + |
| 112 | +The attacker needs to decrypt the on-device wrapping key. Without |
| 113 | +doing that, they can see incidentals like: |
| 114 | +- how many different resident keys you've stored on the device |
| 115 | +- how long each key's RP ID is, if less than 32 characters |
| 116 | +- how long each key's user ID is |
| 117 | +- how many different RPs in total have resident keys on the device |
| 118 | + |
| 119 | +What they can't do without decrypting the wrapping key is get at |
| 120 | +your actual credentials for sites - the private keys, the RP IDs, |
| 121 | +etc. They might - if your device doesn't support transient memory |
| 122 | +for EC private keys AND was inopportunely powered off the last time |
| 123 | +you used it - be able to use the most recently used keypair you did. |
| 124 | + |
| 125 | +#### Decrypting the wrapping key |
| 126 | + |
| 127 | +As described above, the wrapping key is itself encrypted using |
| 128 | +PBKDF2 with a very low iteration count, performed on the first |
| 129 | +sixteen bytes of your PIN's SHA256 hash. This means the attacker is |
| 130 | +unlikely to already HAVE a rainbow table, but they can start |
| 131 | +brute-forcing your PIN. |
| 132 | + |
| 133 | +If you used a strong PIN, you're likely okay for quite a while. |
| 134 | + |
| 135 | +### I left my authenticator plugged into my computer, after entering my PIN |
| 136 | + |
| 137 | +Anyone can use your authenticator as you. Despite what the CTAP2 standard |
| 138 | +says about user presence, it's not readily possible to implement |
| 139 | +a "timeout" on a Javacard 3.0.4 device. Javacard 3.1 introduces an |
| 140 | +(unreliable) uptime counter.... |
| 141 | + |
| 142 | +But the implementation currently always assumes user presence. |
| 143 | + |
| 144 | +This Could Be Better. |
0 commit comments