OpenSTANAG: NATO Data-Centric Security Guard & Cryptographic Binding Engine

Python 3.9+ License: Apache-2.0 Standards: NATO STANAG 4774 / 4778 Zero Trust: NIST SP 800-207 Hugging Face

OpenSTANAG is a complete, high-assurance open-source reference implementation of cross-Atlantic defense, intelligence, and diplomatic Data-Centric Security (DCS) standards. It provides an end-to-end replacement for proprietary commercial solutions (such as ArchTIS Kojensi/NC Protect, Forcepoint High Assurance Guard, and Boldon James Classifier) with 100% official NATO XML Schema conformance.


Standards Implemented

  1. NATO STANAG 4774 (Confidentiality Metadata Label Syntax, ADatP-4774 v1.3):
    • XML vocabulary (urn:nato:stanag:4774:confidentialitymetadatalabel:1:0)
    • Hierarchical security classifications (UNCLASSIFIED, RESTRICTED, CONFIDENTIAL, SECRET, TOP SECRET, COSMIC TOP SECRET)
    • Permissive releasability caveats (REL TO NATO, USA, GBR, AUS, CAN, NZL)
    • Restrictive handling caveats (NOFORN, EYES ONLY)
    • Need-to-know Community of Interest (COI) tagging and Originator ID tracking
  2. NATO STANAG 4778 (Metadata Binding Mechanism, ADatP-4778.2 v1.4 & NCIA TN-1491):
    • Binding Information wrapper (urn:nato:stanag:4778:bindinginformation:1:0)
    • Encapsulated BDO (embedded XML payloads) & Detached/Sidecar BDO (.bdo sidecars)
    • W3C XML Digital Signatures (XMLDSIG) following ADatP-4778.2 Annex A & B
    • Exclusive Canonicalization (http://www.w3.org/2001/10/xml-exc-c14n#)
    • Multi-reference digests over MetadataBinding, SignatureProperties (with OASIS WSU Timestamp), and KeyInfo
    • Real cryptographic signing & verification: RSA-SHA256, ECDSA-SHA256, and HMAC-SHA256
  3. NIST SP 800-207 & SP 800-207A Zero Trust Architecture:
    • Decoupled Policy Decision Point (PDP) and Policy Enforcement Point (PEP)
    • Continuous attribute-based verification
  4. NIST SP 800-63-4 Digital Identity Guidelines:
    • Authenticator Assurance Levels (AAL 1, 2, 3) mapped to sensitivity lattice
  5. OASIS XACML 3.0 / Next Generation Access Control (NGAC):
    • Dynamic ABAC evaluation of Subject citizenship, clearance, and COI attributes
  6. NSA NCDSMO Raise-the-Bar (RTB) RAIN Principles:
    • Redundant, Always Invoked, Independent, Non-bypassable filtering pipeline

Architecture Pipeline

Incoming Document / Stream
           β”‚
           β–Ό
 [ Stage 1: Robust XML Schema Filtering ]  <── Official NATO STANAG 4774 & 4778 XSDs
           β”‚ (Fail -> QUARANTINE)
           β–Ό
 [ Stage 2: Cryptographic Binding Gate ]   <── XMLDSIG (RSA/ECDSA/HMAC, SHA-256)
           β”‚ (Digest/Sig Fail -> QUARANTINE)
           β–Ό
 [ Stage 3: Payload & Sidecar Integrity ]  <── SHA-256 Payload Hash Matching
           β”‚ (Mismatch -> QUARANTINE)
           β–Ό
 [ Stage 4: Zero Trust ABAC PDP Gate ]     <── NIST SP 800-207 & XACML 3.0 Lattice
           β”‚ (Unauthorized -> DENY)
           β–Ό
 [ Stage 5: Tamper-Evident Audit & Release ] ──> Approved Cross-Domain Transfer

Installation

# Clone repository
git clone https://huggingface.co/abr00kx/open-stanag
cd open-stanag

# Install package
pip install -e .

Quickstart

1. Creating a STANAG 4774 Confidentiality Label (Python)

from open_stanag import Stanag4774Label, OriginatorID

label = (
    Stanag4774Label(policy_identifier="NATO", classification="SECRET")
    .add_releasable_to(["NATO", "USA", "GBR"])
    .add_handling_caveat("NOFORN")
)
label.privacy_mark = "EYES ONLY / COI:CYBER"
label.originator_id = OriginatorID("rfc822Name", "ops@shape.nato.int")

# Serialize to XML (automatically validated against official XSD)
xml_str = label.to_xml(validate=True, pretty_print=True)
print(xml_str)

2. Cryptographically Binding with STANAG 4778 & XML-DSig

from open_stanag import (
    Stanag4778Binding,
    generate_rsa_key_and_cert,
    XMLDSigSigner,
    XMLDSigVerifier,
    TrustStore,
)

# Create binding referencing a data object
bdo = Stanag4778Binding.create_simple(
    label=label,
    data_uri="./mission_report.pdf",
    content_type="application/pdf",
    binding_id="mb-report-01",
)

# Generate cryptographic keypair & X.509 certificate
priv_key, cert = generate_rsa_key_and_cert(common_name="guard.nato.int")
signer = XMLDSigSigner(private_key=priv_key, certificate=cert)

# Cryptographically sign in-situ
bdo.sign(signer=signer, target_binding_id="mb-report-01")

# Verify cryptographic signature. The certificate inside the BDO is attacker-controlled,
# so tell the verifier which signers / CAs to trust. Without a trust store, `is_valid`
# reports integrity only and `signer_trusted` is False.
verifier = XMLDSigVerifier(trust_store=TrustStore(anchors=[cert]))
results = bdo.verify_signatures(verifier=verifier)
print("Signature Valid:", results[0].is_valid)
print("Signer Trusted:", results[0].signer_trusted)
print("Signer DN:", results[0].signer_dn)

3. Generating a Sidecar (.bdo) File

from open_stanag import create_sidecar, verify_sidecar

# Create sidecar: writes target_file.pdf.bdo in same directory
bdo_path = create_sidecar(
    target_file_path="./target_file.pdf",
    label=label,
    signer=signer,
)

# Verify sidecar against data object and schema. A signed sidecar carries a detached
# ds:Reference over the file content, so swapping the payload is detected.
result = verify_sidecar(bdo_path, verifier=verifier)
print("Sidecar Valid:", result.is_valid)
print("Signer Trusted:", result.signer_trusted)
print("Payload Matches Signed Digest:", result.payload_hash_valid)
print("Payload SHA-256:", result.computed_payload_sha256)

4. Cross-Domain Guard Evaluation (ABAC PDP/PEP)

from open_stanag import SubjectAttributes, CrossDomainGuard, StanagABACPDP, TrustStore

# Define requesting subject (from identity token or mTLS certificate)
subject = SubjectAttributes(
    subject_id="capt.smith@socom.mil",
    clearance="SECRET",
    citizenship="USA",
    coalition_affiliations={"NATO"},
    aal=2,
)

# The guard fails closed: it releases only objects whose label *and* payload are covered
# by a signature from a signer chaining to one of these anchors. Unsigned, re-signed,
# wrapped or payload-swapped objects are QUARANTINEd.
guard = CrossDomainGuard(
    require_signature=True,
    trust_store=TrustStore(anchors=[cert]),            # or TrustStore.from_pem_files([...])
    pdp=StanagABACPDP(local_nation="USA"),             # originating nation assumed for NOFORN
)
report = guard.inspect_and_filter(bdo_xml_or_path=bdo_path, subject=subject)

print(f"Guard Decision: [{report.decision.value}]")
print(f"Authorized: {report.authorized}")
print(f"Audit ID: {report.audit_id}")
print(f"Reasons: {report.reasons}")

Command-Line Interface (CLI)

# 1. Create a STANAG 4774 label XML
open-stanag label create --policy NATO --classification SECRET \
  --releasable-to NATO,USA,GBR --handling-caveat NOFORN -o label.xml

# 2. Validate label against official NATO XSD
open-stanag label validate label.xml

# 3. Generate a signing key and certificate (test credentials)
open-stanag keygen --out-key signer.key.pem --out-cert signer.cert.pem

# 4. Create a signed sidecar (.bdo) file for any file. The signature covers the label
#    and the file content.
open-stanag sidecar create ./mission.pdf --classification SECRET \
  --releasable-to NATO,USA,GBR --sign --key signer.key.pem --cert signer.cert.pem

# 5. Verify sidecar integrity, payload digest & signer trust
open-stanag sidecar verify ./mission.pdf.bdo --trust-anchor signer.cert.pem

# 6. Execute Cross-Domain Guard inspection. --trust-anchor (a signer or CA certificate,
#    repeatable) makes a trusted signature mandatory; without it the guard only warns.
open-stanag guard inspect ./mission.pdf.bdo \
  --clearance SECRET --citizenship USA --affiliations NATO \
  --trust-anchor signer.cert.pem --local-nation USA

# 7. Launch REST API Guard Server. OPEN_STANAG_TRUST_ANCHORS (PEM paths, ':'-separated)
#    makes the /guard/inspect endpoint require a trusted signature.
OPEN_STANAG_TRUST_ANCHORS=signer.cert.pem open-stanag server --host 127.0.0.1 --port 8000

REST API Endpoints

Method Endpoint Description
GET /health Service health and supported NATO/NIST standards
POST /api/v1/label/create Generates validated STANAG 4774 XML
POST /api/v1/label/validate Validates XML against official STANAG 4774 XSD
POST /api/v1/bind/create Generates and signs STANAG 4778 BDO
POST /api/v1/bind/verify Verifies BDO schema & XML-DSig signature
POST /api/v1/guard/inspect Full Raise-the-Bar RAIN guard inspection & ABAC evaluation

Schema Conformance Guarantee

All generated confidentiality labels and cryptographic bindings are guaranteed to validate 100% against the official NATO Standardization Office schemas located in open_stanag/schemas/:

  • confidentialitymetadatalabel.xsd (NATO UNCLASSIFIED v1.3)
  • bindinginformation.xsd (NATO UNCLASSIFIED v1.4)
  • xmldsig-core-schema.xsd (W3C XMLDSIG-CORE)
  • xmlmime.xsd (W3C XML MIME)

Test Suite

Run the full test suite with 100% pass rate:

python3 -m unittest discover -s tests -p "test_*.py" -v

License

Apache License 2.0. Open-source, freely distributable for defense, coalition, and commercial implementations.

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