YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

vault-live

SAML 2.0 SP/IdP with a NAND-gated assertion validation pipeline.

Every inbound SAML assertion passes through a boolean constraint tree before any attribute is trusted. The constraint tree is written in XML β€” the same language as SAML itself. The entropy of the attribute set is bounded at 0.20 nats. The Semantic Hash produced by the gate is the immutable anchor for the WORM audit chain.

Stack: Python + cryptography library. No lxml, no xmlsec, no external SAML library.
Tests: 31 passing β€” pytest tests/


How it works

IdP produces signed SAML Response
         β”‚
         β–Ό  Base64 decode β†’ XML parse
         β”‚
         β–Ό  Signature verification (RSA-SHA256, enveloped)
         β”‚  uses IdP signing certificate as verification root
         β”‚
         β–Ό  Assertion validation
         β”‚  Conditions: NotBefore / NotOnOrAfter clock check
         β”‚  SubjectConfirmationData: Recipient + expiry
         β”‚  Audience restriction: must match SP EntityID
         β”‚
         β–Ό  Replay protection
         β”‚  assertion ID stored with expiry; duplicate β†’ ReplayDetectedError
         β”‚
         β–Ό  NAND gate  ← constraints.xml is the program
         β”‚  evaluates attribute set through boolean constraint tree
         β”‚  computes Shannon entropy H(attr values) in nats
         β”‚  enforces H <= 0.20
         β”‚  produces Semantic Hash (SHA-256, deterministic)
         β”‚
         β–Ό  WORM audit chain
            AuditRecord appended: semantic_hash, assertion_id, gate_result, H
            SHA-256 chain: entry_hash = SHA256(prev_hash + record_json)
            tamper any record β†’ chain verification fails

The NAND gate

The constraint program lives in nand/constraints.xml. It is XML evaluated against the assertion's attribute map.

NAND(branch1, branch2) = NOT(branch1 AND branch2)

branch1 (session-check):  Role present AND SessionIndex present
branch2 (privilege-escalation):  Role == "SuperAdmin"

VaultUser:  NAND(True, False) = True   β†’ TRUSTED
SuperAdmin: NAND(True, True)  = False  β†’ BLOCKED

The security property: an attacker with maximum privileges satisfies all branches simultaneously, causing NAND to output False. A legitimate user fails at least one "attacker" branch, keeping NAND True.

Entropy constraint: an assertion with multiple distinct values per attribute raises H above 0.20 nats and is rejected regardless of the tree result.

The Semantic Hash binds the assertion identity to the audit record:

semantic_hash = SHA256(
    assertion_id + "|" + issuer + "|" + issue_instant + "|"
    + str(int(tree_result)) + "|" + f"{entropy:.6f}" + "|"
    + json.dumps(sorted_attrs, sort_keys=True, separators=(',',':'))
)

Modules

vault-live/
β”œβ”€β”€ crypto/
β”‚   β”œβ”€β”€ keys.py         RSA key generation, self-signed X.509, PEM load/save
β”‚   β”œβ”€β”€ xml_dsig.py     XML-DSig: RSA-SHA256 sign/verify, Exclusive C14N
β”‚   └── xml_encrypt.py  XML Encryption: AES-256-GCM payload, RSA-OAEP key wrap
β”‚
β”œβ”€β”€ nand/
β”‚   β”œβ”€β”€ constraints.xml  Constraint DSL (vl: namespace) β€” the program IS XML
β”‚   └── gate.py          NANDGate: tree eval, entropy, semantic hash
β”‚
β”œβ”€β”€ saml/
β”‚   β”œβ”€β”€ metadata.xml     SP metadata (EntityID, ACS, signing cert)
β”‚   β”œβ”€β”€ idp_metadata.xml IdP metadata (EntityID, SSO endpoint, signing cert)
β”‚   β”œβ”€β”€ sp/
β”‚   β”‚   β”œβ”€β”€ authn_request.py    AuthnRequest builder + HTTP-Redirect encoding
β”‚   β”‚   └── assertion_consumer.py  ACS: full validation chain + NAND gate
β”‚   └── idp/
β”‚       └── response_builder.py  Response + signed Assertion builder
β”‚
β”œβ”€β”€ audit/
β”‚   β”œβ”€β”€ worm.py    Append-only SHA-256 chain, verify_chain(), AuditRecord
β”‚   └── replay.py  ReplayStore: seen assertion IDs + expiry, file backend
β”‚
└── tests/
    β”œβ”€β”€ test_saml_flow.py   End-to-end: authn request, full flow, replay, tamper
    β”œβ”€β”€ test_nand_gate.py   Gate logic, entropy, semantic hash, constraint DSL
    └── test_audit.py       WORM chain, tamper detection, replay store

Running

pip install cryptography pytest
pytest tests/ -v

Why XML as the constraint language

SAML is XML. The assertions being validated are XML. The SP/IdP metadata is XML. Writing the constraint program in the same language (vl: namespace, nand/constraints.xml) means the trust policy is readable by the same tooling that reads the protocol β€” XPath queries, XML validators, schema checkers, diff tools. GitHub's language detector counts it as XML, which is accurate: the constraint tree is the program.


Built by Ahmad Ali Parr Γ— SnapKitty.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Space using Snapkitty/vault-live 1