notes

NTLMv2, and the operation a secret exposes (removed 2026-08-30)

crates/ntlm and the NTLM path through crates/credentialer and crates/credential_contract were removed from the tree on 2026-08-30, with the SMB implementation that was their only consumer. Read everything below in the past tense; none of it can be built from main. 685900ec is the last commit that holds the code.

Why this note is kept: its design argument is not about NTLM. Hold the key, expose the operation, never the key is what a credential service is for, and the password half (Argon2id, verify::VERIFY) still ships and works that way. What went is one protocol's arithmetic.

And the removal is itself the lesson. DECISIONS §79 approved holding password-equivalent material (an NTOWFv2, crackable at roughly the speed of MD4, beside an Argon2id tag that is not) and approved three known-broken hash functions to go with it. Its justification was NTLMv2 protocol compliance: nothing here chose MD4 and MD5, the specification did. That was sound, and contingent on a protocol to comply with. When the customer moved and the SMB implementation went, the premise evaporated and nothing noticed: every gate stayed green, cargo-deny stayed happy, and the crate's documented security property was still true of the crate. A dependency taken for a stated reason has to be re-checked when the reason changes, and a decision record naming its own premise is what makes that possible. §79 is now stale and needs amending; that is an architect's. See notes/smb.md for the whole account.

What follows is the note as it stood before the removal.

Milestone 65: hold the key, expose the operation, never the key. The half of the secrets service that lets an SMB server authenticate a Mac without ever holding the thing that authenticates it.

The arithmetic is crates/ntlm, the store is crates/credentialer, the wire contract is crates/credential_contract, and the service is components/src/credentialer.rs. The password half of the same store is credentials, and every salt in it comes from entropy.

The observation that made this a milestone

Milestone 56 wrote down the principle: hand out the operation, not the secret. It then assumed the operation, and the assumption was wrong.

NTLMv2 does not verify a presented secret. The client never sends the password, and the server receives nothing it can compare against a stored tag. The server holds a key, computes a MAC over a challenge it chose, and compares that to the client's MAC. The NT hash is a key the server computes with, not a verifier, and "secret in, boolean out" does not describe the operation.

That is why 65 is a milestone rather than a second opcode on the credentialer. The principle survived; the shape did not.

What the service holds, and what it computes

  password ──MD4(UTF-16LE)──► NT hash ──HMAC-MD5 over UPPER(user)||domain──► NTOWFv2
                                                                               │
     ····························································  provisioning ends here
                                                                               │
  server challenge (8) ┐                                                       │
  the client's blob    ├──────────────HMAC-MD5 keyed by NTOWFv2────────────────┤
                       ┘                                                       ▼
                                                                         NTProofStr (16)
                                                                               │
                                   HMAC-MD5 keyed by NTOWFv2 over NTProofStr ──┤
                                                                               ▼
                                                                    SessionBaseKey (16)

Above the dotted line happens once, at provisioning, from a password the provisioner holds in the clear. Below happens per authentication, from public inputs.

The store holds NTOWFv2, not the NT hash, a design decision with two consequences.

The account name and the domain are bound at provisioning time, so a caller of the runtime operation cannot choose them. A caller that could would be choosing half the key derivation, which is how "compute a proof" quietly becomes "compute a proof for Administrator". The runtime request therefore carries only public inputs: a resource name, a challenge, a blob, and a proof.

And a stolen NTOWFv2 authenticates as one account in one domain, where a stolen NT hash authenticates as that account anywhere the password was reused. Reuse is what normally makes password-equivalent storage dangerous, and per-resource scoping cuts it at the root.

The operation, and why it is folded

Milestone 65's own table names the operation ntlm_response(challenge) -> response. What shipped is NTLM_PROOF: is this the proof a holder of the password would have computed, and if so, here is the session key. The proof is computed inside and compared inside; it never leaves.

Folding the comparison in is the move VERIFY makes for a password, and it is strictly stronger, because anything that can obtain the expected proof can do the comparison itself. The unfolded version is what an SMB client needs, and nothing in this tree is one. Milestone 55 is a server: calef's Mac connects to nife as a Time Machine target.

If an SMB client ever arrives, the unfolded operation is a new opcode and a decision to make on purpose, not a gap to fill in quietly.

What crosses the boundary

This is the question DECISIONS §25 forces, because the frame is the real granted resource: a secrets capability that hands back a shared frame full of key material has defeated itself.

Never, under any opcode, in any reply, in any page: the Argon2id salt, the Argon2id tag, the NT hash, NTOWFv2. There is no message that would return one. There is also no message that answers "does this resource exist", "which kinds of secret does it have", or "how many are there".

Crosses, once, on a match: the 16-byte SessionBaseKey, written into the shared page at cred_proto::SESSION_KEY_OFF.

It crosses because an SMB server that cannot sign the session it authenticated cannot serve SMB2, so a boolean-only operation would be useless for its purpose. It is defensible because the value is a function of the stored key and of a challenge this server chose and a client challenge inside the client's blob. It is per-session, it signs one session, and recovering the key it came from is an HMAC key recovery.

It is released only against a proof that verified, which a caller cannot manufacture without the key it does not hold. The rule is "prove that a real client authenticated, and receive that session's key".

A stricter design exists: keep the session key inside too and expose signing as a further operation. That is the same move one level up, it is where milestone 65's third row (a signing key) would take this, and it is not what shipped.

Two hazards the store handles that a naive one would not

A record with no NTLM half must never answer. The first design left its key as sixteen zero bytes, which is a key an attacker knows: anyone could compute the proof under it and be told MATCH. Filling it with entropy instead works and was the second design, but it makes every provisioning path need a randomness source for a field nothing reads. What shipped is a has_ntlm flag, folded into the verdict after the MAC has run, so it costs no branch anybody can time. credentialer's tests present exactly that forgery and require the answer to be no.

A refusal must cost what an acceptance costs. The session key is derived on every well-formed request and then zeroed by conditional assignment rather than skipped by a branch, and the lookup that finds the record is the same branch-free scan the password half uses. A miss on a resource nobody provisioned and a wrong proof on one that exists are the same reply and the same work.

Three broken primitives, on purpose

MD4, MD5 and HMAC-MD5 are what NTLMv2 specifies. Shipping them is protocol compliance, not a security choice, as implementing DES to talk to old hardware does not endorse DES. What matters is what is stored and what is claimed about it.

They arrive as dependencies, which is DECISIONS §46 applied unchanged: depend rather than vendor, so cargo-deny and cargo-audit can see the graph, and make the specification's own answers the tests. md4 0.10, md-5 0.10 and hmac 0.12 add four crates to a graph that already had digest under Argon2, and script/supply-chain passes unchanged: advisories, licenses, bans, sources.

The blast radius, stated plainly: a record with an NTLM half is crackable offline at roughly the speed of MD4, whatever the Argon2id cost beside it says. Provisioning one lowers that record's offline strength to the weaker of its two derivations. That is the price of speaking NTLMv2, it is bounded by scope rather than by strength (a cracked key opens one share), and Record::derive_ntlm says so where the choice is made.

The vectors are the point

A dependency whose answers you never check is one you have merely hoped about. So:

The last pins our wiring rather than the libraries' arithmetic: the UTF-16LE encoding, which of the two names is uppercased, the order of the challenge and the blob, and the key each HMAC runs under. It is transcribed twice on purpose, once in crates/ntlm and once in crates/credentialer, because the two crates should be checked against the published document and not against each other.

A correction worth keeping. The first transcription of the blob carried four extra trailing zeros, and every value up to NTOWFv2 still matched, because the blob enters the chain only at the proof. The machine caught it at one assertion, where it looked like a bug in the code under test. A vector transcribed by shape rather than by count is a vector that lies.

EXAMPLES

Provision a share, then seal the store

From a provisioner holding the provision endpoint in slot 0 and its page mapped. A share is a resource name, a password, and the account name and domain the key is bound to.

use cred_proto as proto;

let page = /* the mapped provision page, 4096 bytes */;
for (resource, password, user, domain) in [
    (&b"backups-alice"[..],   &b"Password"[..], &b"User"[..],    &b"Domain"[..]),
    (b"backups-bob",          b"another share secret", b"bob",   b"WORKGROUP"),
    (b"backups-carol",        b"a third share secret", b"carol", b"WORKGROUP"),
] {
    let (w0, w1) = proto::place_ntlm_put(page, resource, password, user, domain).unwrap();
    let (r0, _) = call(SERVICE, w0, w1);
    assert_eq!(r0, proto::OK);
}

let w0 = proto::place(page, b"seal", b"seal", proto::provision::SEAL).unwrap();
call(SERVICE, w0, 0);

The account name and the domain go in the second request word's length fields; they are the only fields in this contract that do.

Answer a client's authentication

From an SMB server holding the verify endpoint in slot 0. It has the challenge it issued and the NtChallengeResponse the client sent, which is NTProofStr || temp, so it already has both halves and never needs the service to split them.

let (proof, blob) = ntchallengeresponse.split_at(proto::KEY_LEN);
let w0 = proto::place_ntlm_proof(
    page,
    b"backups-alice",
    &server_challenge,          // the 8 bytes we put in the CHALLENGE_MESSAGE
    blob,                       // the client's temp, unexamined
    proof.try_into().unwrap(),
).unwrap();

let (r0, _) = call(SERVICE, w0, 0);
if proto::is_authenticated(r0) {
    let session_key = proto::session_key(page).unwrap();
    // ... derive the SMB2 signing key from it, sign the session ...
}
proto::wipe(page);              // the key is ours now; it should not outlive the exchange

is_authenticated is the whole client-side verdict API, and it collapses "there is no secrets service", "the request was malformed", "the service died" and "the proof is wrong" into one false. Testing whether the session key is nonzero instead would be a second, weaker authentication check sitting beside the real one.

Check the chain without a service (host, in a test)

let key = ntlm::ntowfv2(b"Password", b"User", b"Domain").unwrap();
let proof = ntlm::proof(&key, &server_challenge, &blob);
let session = ntlm::session_base_key(&key, &proof);

The service's API has no store.ntowfv2_for(), no way to ask the store for a key. crates/ntlm is a function of inputs a caller already has; crates/credentialer is where the secret lives, and it has no getter.

What is proven, and where

Host tests (cargo test -p ntlm -p credentialer -p credential_contract, milliseconds, no emulator):

Proofs (script/verify, five Kani harnesses over cred_proto, 30 checks, 0.16 s; two are new):

Guest tests (kernel::user::credential_tests, on aarch64 and riscv64, same assertions):

BUGS