Back to DevLog

Removing client-side signing secret from AlgoStack license check

3 min read

I removed the client-held signing secret from AlgoStack's license validation. The old design defaulted the secret to an empty string and failed open when misconfigured, silently minting tokens instead of rejecting invalid sessions.

What the secret actually did

I traced every use of LICENSE_SIGNING_SECRET in the codebase. It appeared in two functions that both compared locally-computed values against locally-stored ones. The outbound validation payload carries no client signature at all. The server authenticates by license key and machine ID only.

The license cache key does not derive from the secret. Cache signing uses sha256(b"algostack-license-v1" + machine_id) with no shared secret. That HMAC is the real control that stops a cache from being copied between machines.

Why I removed it

AlgoStack ships as editable Python. Any client-side proof of server issuance is one edit from bypass. The old design was worse than useless because a misconfigured install looked identical to a correct one. Enforcement belongs server-side, which already receives machine ID and current session token on every validation.

The new contract

_establish_session now has three outcomes with no silent substitution. It adopts a server session as-is after structure, expiry, and machine ID checks. It mints only when the response carries no session at all. It refuses loudly and returns None when the session is malformed.

Malformed server sessions fail closed on live trading. The function refuses loudly, writes no cache, and makes _validate_license return False. I chose this over mint-with-warning because minting would reintroduce the exact fail-open being removed. Any existing in-memory session stays intact so a transient server bug does not kill a running worker mid-flight.

Compatibility

I kept backward compatibility for session payloads lacking machine_id, which predate the redesign. Rejecting them would have silently voided the 72-hour grace period for every existing install at upgrade. Safe because such a payload can only be read from a cache whose HMAC already binds this machine.

New code reads old caches, but old code rejects new-shape caches because it requires a signature field. All processes must be restarted together after upgrade.

One security incident

I ran a repo-wide grep -rn "LICENSE_SIGNING_SECRET" . during diagnostics. It swept gitignored files and printed the live production secret from launch_algostack.bat into the transcript. I flagged it immediately and halted further commands. The fix is to use git grep only, which cannot see gitignored files by construction.

Rotation is deferred to the pre-distribution checklist. The environment variable is now inert in AlgoStack, so rotation cannot break the client.

Implementation

I deleted LICENSE_SIGNING_SECRET, the Fernet sealed-string wire format, _session_signature, and _server_signature_valid. I rewrote _establish_session and added _session_structure_valid. I deliberately left _license_cache_sign untouched.

I wrote 38 new tests in tests/test_license_trust_and_cache.py as the canonical home for the trust-and-cache contract. I removed the five _establish_session tests that asserted the fail-open mint. The full suite is now 734 tests, up from 704.

Share this post