Open table of contents
Make the claim precise before making the proof bigger
Treating formal verification as a final proof of an entire completed system creates a large starting point. Everyday development can begin with a small boundary that must not fail: destructive actions without approval, restarting a terminal job, or replaying a signed capability.
Rust’s type and ownership guarantees matter, but they do not establish business authorization or protocol correctness. The Rust Reference distinguishes declarations of unsafe contracts from the places responsible for satisfying them.[1] An authorization function written entirely in safe Rust can still confuse && with ||.
This article moves from a small authorization requirement through Rust, Kani harnesses, Tamarin attack traces and a CI gate. Keep each property, model and assumption near the code instead of applying one “formally verified” label to the system.
Download the complete example, including Rust sources, two Tamarin models, verification scripts and an assurance record. These are authored design examples: Rust tests, Kani and Tamarin were not executed for publication. Counterexamples below are explained from the code and model; they are not captured tool transcripts or measured performance results.
State the property in one sentence
| ID | Property to establish | Primary target |
|---|---|---|
| AUTH-DELETE | An allowed DeleteData request requires Admin and approval | Pure Rust authorization core |
| FLOW-ENTRY | Executing is entered only through Approved plus Start | A single Rust state transition |
| CAP-ORIGIN | Acceptance has prior issuance or prior compromise of the relevant key | Symbolic protocol |
| CAP-ONCE | The same capability never produces two acceptance events | Protocol with consumption state |
Rust can make invalid states harder to represent. Unit and property tests examine concrete behavior. Kani model-checks Rust reachable through a harness. Tamarin examines protocol traces under an explicit attacker and cryptographic model. These are different targets, not successive rungs proving the same system more strongly.
Scroll horizontally to view the complete diagram.
Read the diagram as text
Rust types constrain representation and ownership; tests and fuzzing exercise concrete executions; Kani checks implementations within harness scope; Tamarin analyzes symbolic protocol traces; telemetry observes deployed behavior. None automatically establishes whole-system assurance.
1. Build a small authorization core in Rust
The example is a library without external dependencies. Its Cargo manifest registers Kani’s conditional compilation name and separates the intentionally broken example from normal verification.
[package]
name = "boundary-assurance"
version = "0.1.0"
edition = "2024"
publish = false
[features]
negative-control = []
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(kani)'] }
src/lib.rs exposes authorization and workflow; the negative control is included only under cfg(all(kani, feature = "negative-control")). The types and corrected implementation in src/authorization.rs are:
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(kani, derive(kani::Arbitrary))]
pub enum Action {
Read,
Restart,
RotateKey,
DeleteData,
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(kani, derive(kani::Arbitrary))]
pub enum Role {
Reader,
Operator,
Admin,
}
#[derive(Copy, Clone, Debug)]
#[cfg_attr(kani, derive(kani::Arbitrary))]
pub struct Request {
pub role: Role,
pub action: Action,
pub approved: bool,
}
pub fn authorize(req: Request) -> bool {
match req.action {
Action::Read => true,
Action::Restart => matches!(req.role, Role::Operator | Role::Admin),
Action::RotateKey => req.role == Role::Admin,
Action::DeleteData => req.role == Role::Admin && req.approved,
}
}
cfg_attr(kani, derive(kani::Arbitrary)) enables generation of valid enum and struct values during Kani verification without adding that derive to a normal build.[2] This request has 24 combinations: three roles, four actions and two approval values. That space does not include invalid enum representations or forged role claims from an external caller.
The approval Boolean is an abstraction chosen to keep the example small. A production adapter would establish identity, authority, approver, target, action, arguments and expiry before constructing a request. This is not an API design that trusts a caller-supplied approved flag.
2. Catch a bug that representative examples miss
Suppose the delete branch originally read:
Action::DeleteData => req.role == Role::Admin || req.approved,
Tests for an unapproved Reader being denied and an approved Admin being allowed both pass. Yet an approved Operator and an unapproved Admin are also allowed. The requirement is conjunction; the implementation uses disjunction.
Retain those boundaries as regression examples after correction:
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn delete_examples() {
let cases = [
(Role::Reader, false, false),
(Role::Admin, true, true),
(Role::Operator, true, false),
(Role::Admin, false, false),
];
for (role, approved, expected) in cases {
let req = Request {
role,
action: Action::DeleteData,
approved,
};
assert_eq!(authorize(req), expected);
}
}
}
Concrete examples remain useful executable documentation. A Kani harness states the property over nondeterministic input:
#[cfg(kani)]
mod verification {
use super::*;
#[kani::proof]
fn delete_requires_admin_and_approval() {
let req: Request = kani::any();
if req.action == Action::DeleteData && authorize(req) {
assert_eq!(req.role, Role::Admin);
assert!(req.approved);
}
}
#[kani::proof]
fn delete_policy_is_exact() {
let role: Role = kani::any();
let approved: bool = kani::any();
let req = Request {
role,
action: Action::DeleteData,
approved,
};
assert_eq!(authorize(req), role == Role::Admin && approved);
}
#[kani::proof]
fn other_actions_follow_policy() {
let req: Request = kani::any();
match req.action {
Action::Read => assert!(authorize(req)),
Action::Restart => {
assert_eq!(authorize(req), req.role != Role::Reader);
}
Action::RotateKey => {
assert_eq!(authorize(req), req.role == Role::Admin);
}
Action::DeleteData => {}
}
}
}
kani::any() is not random sampling. It introduces nondeterministic values within the selected types and harness constraints. Kani checks assertions, panics, arithmetic overflow and other conditions, but does not support every Rust feature or every form of undefined behavior. Review the selected version’s support and diagnostics.[2][4]
For example, run:
cargo kani --harness delete_requires_admin_and_approval
cargo kani --harness delete_policy_is_exact
The first harness checks an implication: allowed deletes satisfy the conditions. The second also requires eligible deletes to be allowed. It prevents an implementation that rejects everything from satisfying only the safety implication. However, copying the implementation into a property can reproduce the same specification mistake; review the requirement independently.
The deliberately incorrect OR implementation remains in a separate module:
cargo kani --features negative-control --harness finds_or_bug
An assertion counterexample is expected for this negative control. Operator / DeleteData / approved = true violates the property, but no particular first counterexample or reporting order is assumed. Installation failure or timeout is not the expected failure.
3. Separate state transitions from authority to issue commands
src/workflow.rs defines five states and four commands:
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(kani, derive(kani::Arbitrary))]
pub enum JobState {
Pending,
Approved,
Executing,
Done,
Failed,
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(kani, derive(kani::Arbitrary))]
pub enum Command {
Approve,
Start,
Complete,
Fail,
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum TransitionError {
InvalidTransition,
}
pub fn transition(
state: JobState,
command: Command,
) -> Result<JobState, TransitionError> {
match (state, command) {
(JobState::Pending, Command::Approve) => Ok(JobState::Approved),
(JobState::Approved, Command::Start) => Ok(JobState::Executing),
(JobState::Executing, Command::Complete) => Ok(JobState::Done),
(JobState::Executing, Command::Fail) => Ok(JobState::Failed),
_ => Err(TransitionError::InvalidTransition),
}
}
This function checks a state/command pair. It does not establish who may issue Approve, whether the approved payload changed or whether another database worker is racing with it. Naming an enum variant Approved does not establish authorization.
Check entry conditions with this harness:
#[cfg(kani)]
#[kani::proof]
fn entry_states_are_restricted() {
let state: JobState = kani::any();
let command: Command = kani::any();
if let Ok(next) = transition(state, command) {
if next == JobState::Executing {
assert_eq!(state, JobState::Approved);
assert_eq!(command, Command::Start);
}
if next == JobState::Done {
assert_eq!(state, JobState::Executing);
assert_eq!(command, Command::Complete);
}
}
// Prevent an always-Err implementation from satisfying everything.
assert_eq!(
transition(JobState::Approved, Command::Start),
Ok(JobState::Executing)
);
assert_eq!(
transition(JobState::Executing, Command::Complete),
Ok(JobState::Done)
);
}
Arbitrary states include more than states known to be reachable from the initial state. This is a local property about successful transitions. The concrete assertions at the end prevent an always-Err implementation from satisfying every implication vacuously.
Types can also narrow the execution API. An ApprovedDelete type with private fields could retain a validated resource and approval identifier. Private fields or omitting Copy do not independently prevent distributed replay or later revocation. Constructors, deserialization, restoration and execution-time revalidation remain part of the boundary.
4. Distinguish the input bound from the unwinding bound
For a sequence of operations, choose the input scope explicitly. This driver attempts eight commands from Pending and preserves state when a transition is invalid:
#[cfg(kani)]
#[kani::proof]
#[kani::unwind(9)]
fn terminal_states_do_not_restart_in_eight_steps() {
let commands: [Command; 8] = kani::any();
let mut state = JobState::Pending;
let mut index = 0;
while index < commands.len() {
let before = state;
if let Ok(next) = transition(state, commands[index]) {
state = next;
}
if matches!(before, JobState::Done | JobState::Failed) {
assert_eq!(state, before);
}
index += 1;
}
}
[Command; 8] defines the sequence length. #[kani::unwind(9)] configures loop expansion; it does not mean nine commands were verified. Even a simple loop needs a final condition check, and generated control flow can require additional expansion.[3]
An unwinding assertion failure is insufficient exploration, not success up to the chosen number. Bound the problem, then establish that expansion is sufficient for that bounded input. Do not silently shrink input or disable unwinding assertions to make the result green.
The claim here is that terminal states remain unchanged within this eight-attempt driver. It does not cover arbitrary-length executions, concurrent database updates or restored jobs.
Kani also provides loop and function contracts. The consulted documentation describes experimental flags -Z loop-contracts and -Z function-contracts.[5] Invariant abstraction and termination are different obligations; a contract does not automatically prove every loop. This article’s baseline uses ordinary harnesses.
5. Model the protocol outside the Rust function with Tamarin
A pure Rust function does not expose network interception, substitution or replay. Tamarin models participants, messages, attacker knowledge, cryptography and state with multiset rewriting, then expresses properties over events in traces.[6]
Consider an authority signing a capability and a service accepting it. The signed tuple includes a domain tag, key identifier, service, user, resource, action and nonce. Including a user name does not authenticate the presenter. This example sends a bearer capability over a public network; it does not prevent an attacker from using it first or provide confidentiality.
The complete formal/capability-stateless.spthy theory is:
theory CapabilityStateless
begin
builtins: signing
rule RegisterAuthority:
[ Fr(~kid), Fr(~sk) ]
-->
[ !AuthorityKey(~kid, ~sk)
, !AuthorityPk(~kid, pk(~sk))
, Out(<~kid, pk(~sk)>)
]
rule RegisterService:
[ Fr(~sid) ]
-->
[ !Service(~sid), Out(~sid) ]
rule RevealAuthorityKey:
[ !AuthorityKey(kid, sk) ]
--[ KeyReveal(kid) ]->
[ Out(sk) ]
rule IssueCapability:
let cap = <'cap-v1', kid, S, $U, $R, $Act, ~nonce>
in
[ !AuthorityKey(kid, sk), !Service(S), Fr(~nonce) ]
--[ Issued(kid, S, cap) ]->
[ Out(<cap, sign(cap, sk)>) ]
rule UseCapability:
let cap = <'cap-v1', kid, S, U, R, Act, nonce>
in
[ !AuthorityPk(kid, pkA), !Service(S), In(<cap, sig>) ]
--[ Eq(verify(sig, cap, pkA), true)
, Accepted(kid, S, cap)
]->
[]
restriction Equality:
"All x y #i. Eq(x,y) @i ==> x = y"
lemma executable:
exists-trace
"Ex kid S cap #i #j.
Issued(kid,S,cap) @i & Accepted(kid,S,cap) @j
& i < j
& not (Ex k #r. KeyReveal(k) @r)"
lemma accepted_requires_issuance:
"All kid S cap #i.
Accepted(kid,S,cap) @i ==>
((Ex #j. Issued(kid,S,cap) @j & j < i)
| (Ex #r. KeyReveal(kid) @r & r < i))"
lemma capability_cannot_be_replayed:
"All kid S cap #i #j.
Accepted(kid,S,cap) @i & Accepted(kid,S,cap) @j
==> i = j"
end
Fr generates fresh values. Each authority key receives a fresh key identifier, so the compromise exception refers to the key actually used, rather than an ambiguous organization name. The persistent AuthorityPk fact represents trusted key installation, not a public-key registry that the attacker can rewrite. The service identity in the message is matched with the local service fact.
The signing built-in provides symbolic equations including verify(sign(m,sk),m,pk(sk)) = true.[6] Emitting Eq alone does not enforce equality, so the Equality restriction is necessary. It represents an implementation accepting only after successful verification. Do not add a restriction directly prohibiting replay: that would assume the desired conclusion.
The issuer rule does not call Rust’s authorize() function. It can issue for arbitrary public user, resource and action names. Placing the two checks together does not compose them into an end-to-end authorization proof. Correspondence between issuance policy and Rust authorization remains an explicit obligation.
6. Establish executability first
The executable lemma requires an uncompromised trace with issuance before acceptance. If acceptance is unreachable, many security implications hold vacuously. The Tamarin manual recommends checking executability to avoid that modeling error.[7]
The origin lemma requires earlier issuance or earlier compromise of the particular key. Compromise after acceptance does not excuse an earlier invalid acceptance. This property establishes message provenance, not issuance policy, expiry or authentication of the bearer.
tamarin-prover formal/capability-stateless.spthy \
--prove --quit-on-warning
If automatic search completes, the model is intended to yield verified for executability and origin, and falsified for replay prevention. These are expected outcomes, not results obtained for this article. Tamarin search need not terminate; larger theories may require supporting lemmas or interactive proof work.[8]
7. A valid signature does not prevent replay
The public key and service facts used by UseCapability are persistent. No unique acceptance state is consumed. An attacker can learn the signed capability from Out and provide it repeatedly to In:
Issue(cap, signature)
→ attacker learns the signed message
→ UseCapability → Accepted(cap)
→ replay the same message
→ UseCapability → Accepted(cap)
The acceptance events occur at different times, violating the replay lemma’s equality condition. No signature forgery is needed. Provenance and single use are different properties.
Scroll horizontally to view the complete diagram.
Read the diagram as text
A stateless service can accept the same signed capability twice. A model that creates one linear Unused fact and consumes it at acceptance has no fact left for replay. Implementation requires unique, atomic and durable consumption; this is separate from exactly-once business completion.
8. Represent single acceptance with consumable state
For formal/capability-once.spthy, change the theory name to CapabilityOnce and replace these two rules. All other rules and lemmas remain the same:
rule IssueCapability:
let cap = <'cap-v1', kid, S, $U, $R, $Act, ~nonce>
in
[ !AuthorityKey(kid, sk), !Service(S), Fr(~nonce) ]
--[ Issued(kid, S, cap) ]->
[ Out(<cap, sign(cap, sk)>), Unused(S, cap) ]
rule UseCapability:
let cap = <'cap-v1', kid, S, U, R, Act, nonce>
in
[ !AuthorityPk(kid, pkA), !Service(S)
, Unused(S, cap), In(<cap, sig>) ]
--[ Eq(verify(sig, cap, pkA), true)
, Accepted(kid, S, cap)
]->
[]
Unused has no exclamation mark. Once consumed, that linear fact cannot be reused. A fresh nonce on every issuance also prevents another issuance from replenishing state for the same capability. This linear/persistent distinction models single acceptance.[6]
The corrected design is intended to satisfy all three lemmas. However, the trusted Unused registry also limits acceptance to issued capabilities. Origin in this model therefore does not independently establish that signature validation is correctly enforced. A mutation removing signature checking should also be examined in the stateless model, where the registry cannot mask that defect.
Inspect why a property holds. A stronger assumption can make a proof succeed without improving the behavior you intended to examine.
9. Map the linear fact to atomic implementation state
A stateless JWT implementation has no equivalent of Unused. Applying the model’s single-use claim requires trusted registration, atomic consumption, durable committed state and coordination across workers. Restoring stale consumption state during failover breaks the correspondence.
One possible PostgreSQL boundary combines consumption and execution-job creation in a transaction. This is an architectural SQL sketch:
BEGIN;
WITH consumed AS (
DELETE FROM unused_capability
WHERE issuer_key_id = $1
AND service_id = $2
AND capability_id = $3
AND payload_hash = $4
RETURNING capability_id
)
INSERT INTO execution_job (operation_id, capability_id, status)
SELECT $5, capability_id, 'pending'
FROM consumed
RETURNING operation_id;
COMMIT;
Capability registration must be unique, and the execution job needs appropriate uniqueness constraints. Validate the signature, target and current authority against the same payload being consumed. This SQL does not establish parser correctness, authorization or database failover guarantees.
Map acceptance to one returned row plus confirmed commit. A lost commit response means an uncertain result; reconcile by operation identity. Job acceptance is not exactly-once completion of an external effect.
The Tamarin claim is at most one Accepted event, not exactly one successful business outcome. Availability, termination and crash recovery require separate claims.
10. Record implementation correspondence and its limits
| Model element | Implementation counterpart | Additional obligation |
|---|---|---|
| AuthorityPk | Trusted key installation and key identity | Registration authority, rotation and revocation |
| Eq and signing | Canonical bytes and signature verification | Parser, domain separation and cryptographic library |
| Unused | Unique unused-capability record | Concurrent consumption, durability and failover |
| Accepted | Committed consumption and job registration | Unknown commit, duplicate workers and audit |
| KeyReveal | Abstract key-compromise event | Detection, revocation and incident response |
Tamarin does not verify the Rust parser, serialization, certificate validation or constant-time cryptographic implementation. The local Kani harness does not establish external IAM or database concurrency. The consulted Kani support table places concurrent features outside scope and notes that they can be compiled as sequential code.[4] Do not overlook that warning and report a concurrency proof.
Separate HTTP and database adapters from a pure domain core. If a stub replaces behavior, record the substitution as an assumption. Small scope is useful; hidden assumptions are not.
11. Distinguish vacuity and incompleteness from success
After kani::assume(false), assertions are unreachable. Kani’s FAQ recommends kani::cover! when unexpected UNREACHABLE results suggest an overconstrained harness.[4] Here, positive authorization and successful-transition assertions also prevent simple vacuous implementations.
| Result | Interpretation |
|---|---|
| Violating input or attack trace | Reproduce it and revise the requirement or implementation |
| Timeout or incomplete search | Insufficient evidence |
| Unsupported feature or wellformedness warning | Stop the gate and inspect the model or toolchain |
| Intended behavior unreachable | Investigate overconstraint, missing behavior or vacuity |
| All obligations completed | Retain evidence tied to target, assumptions and bounds |
Review a new assumption or deleted property as carefully as an implementation change. Ask what is no longer claimed, rather than only whether verification now passes.
12. Make CI check obligations, not just process completion
A verifier finishing does not mean every lemma was proved. Tamarin provides automatic search with --prove and warning-triggered stopping with --quit-on-warning.[8] Also require the expected lemma names, trace types and outcomes.
The example’s check_tamarin.py reads the summary format documented by the manual. It is an integration gate, not an independent mathematical proof checker:
#!/usr/bin/env python3
"""Strict summary gate for the documented Tamarin CLI format; not a proof checker."""
from pathlib import Path
import re
import sys
expected = {
"stateless": {
"executable": ("exists-trace", "verified"),
"accepted_requires_issuance": ("all-traces", "verified"),
"capability_cannot_be_replayed": ("all-traces", "falsified"),
},
"once": {
"executable": ("exists-trace", "verified"),
"accepted_requires_issuance": ("all-traces", "verified"),
"capability_cannot_be_replayed": ("all-traces", "verified"),
},
}
mode, log_path = sys.argv[1:]
text = Path(log_path).read_text()
if re.search(r"(?im)^\s*(WARNING|ERROR)\b|wellformedness checks failed", text):
raise SystemExit("Tamarin warning/error: inspect the full log")
_, marker, summary = text.rpartition("summary of summaries:")
if not marker:
raise SystemExit("Missing complete summary")
rows = re.findall(
r"(?m)^\s*(\w+)\s+\(([^)]+)\):\s+([^\n]+)$", summary,
)
actual = {}
for name, trace_type, report in rows:
status = re.match(r"(verified|falsified)(?=\s|$)", report)
if not status:
raise SystemExit(f"Incomplete or unknown outcome: {name}: {report}")
if name in actual:
raise SystemExit(f"Duplicate lemma: {name}")
actual[name] = (trace_type, status.group(1))
if len(rows) != len(actual) or actual != expected[mode]:
raise SystemExit(f"Unexpected or incomplete lemma results: {actual}")
print(f"{mode}: all expected lemma outcomes present")
Only the stateless replay lemma is expected to be falsified as an intentional negative control. The corrected once model requires every lemma to be verified. Missing, duplicate, mismatched, incomplete or unknown results must not pass. A changed output format after a tool update should require parser review rather than silent acceptance.
For Kani, list the required harnesses explicitly so deleting one cannot leave only the remaining checks green. The local verification script is:
#!/usr/bin/env bash
set -euo pipefail
export NO_COLOR=1 CARGO_TERM_COLOR=never
cd "$(dirname "$0")/.."
mkdir -p evidence
# CI must provision and identify a reviewed, immutable environment first.
: "${FORMAL_TOOLCHAIN_ID:?Set the reviewed OCI image digest}"
if [[ ! "$FORMAL_TOOLCHAIN_ID" =~ @sha256:[0-9a-f]{64}$ ]]; then
echo "An immutable OCI image reference is required" >&2
exit 2
fi
printf '%s\n' "$FORMAL_TOOLCHAIN_ID" > evidence/environment.txt
rustc -vV > evidence/rust.txt
cargo kani --version > evidence/kani.txt
tamarin-prover --version > evidence/tamarin.txt
maude --version > evidence/maude.txt 2>&1
python3 --version > evidence/python.txt 2>&1
python3 - <<'PY'
from pathlib import Path
import re
for file, pattern in [
("rust", r"(?m)^release: 1\.99\.0$"),
("kani", r"\b0\.68\.0\b"),
("tamarin", r"\b1\.12\.0\b"),
]:
if not re.search(pattern, Path(f"evidence/{file}.txt").read_text()):
raise SystemExit(f"Unexpected {file} version")
PY
cargo fmt --check 2>&1 | tee evidence/fmt.log
cargo clippy --locked --all-targets -- -D warnings 2>&1 | tee evidence/clippy.log
cargo test --locked 2>&1 | tee evidence/test.log
# Explicit harness inventory: removing or renaming one must fail this gate.
for harness in \
delete_requires_admin_and_approval \
delete_policy_is_exact \
other_actions_follow_policy \
entry_states_are_restricted \
terminal_states_do_not_restart_in_eight_steps
do
timeout --kill-after=5s 120s cargo kani --harness "$harness" \
2>&1 | tee "evidence/kani-${harness}.log"
if grep -Ei '^[[:space:]]*(warning|error)(:|\[)' "evidence/kani-${harness}.log"; then
echo "Kani warning/error requires review" >&2
exit 1
fi
grep -q '^VERIFICATION:- SUCCESS$' "evidence/kani-${harness}.log"
done
for model in stateless once; do
timeout --kill-after=5s 120s tamarin-prover \
"formal/capability-${model}.spthy" --prove --quit-on-warning \
2>&1 | tee "evidence/tamarin-${model}.log"
python3 scripts/check_tamarin.py "$model" "evidence/tamarin-${model}.log"
done
Pipefail prevents tee from hiding verifier failure. A timeout stops the gate as incomplete, and Tamarin outcomes receive an additional summary check. The 120-second budget is illustrative, not a measured runtime or performance claim. Kani’s negative control is a separate command from the ordinary success gate.
13. Pin the toolchain and retain evidence
The proposed baseline is Rust 1.96.0, Kani 0.67.0 and Tamarin 1.12.0. These versions were checked against official distribution and release information, not validated together by running this example. Kani 0.67.0 pins nightly-2025-11-21 in its source; its internal compiler is distinct from the normal Rust toolchain.[9]
Cargo.lock does not pin Kani, Tamarin, Maude, solvers or operating-system dependencies. With Nix, retain the adopted derivations and flake.lock. With containers, retain a reviewed image digest covering the complete toolchain. This article provides neither a fictitious image digest nor a claim of a validated Nix environment.
The CI template uses an actual immutable image configured by the repository administrator. It assumes the example is at the target repository root and the environment has already been provisioned:
# Copy to .github/workflows/formal.yml after provisioning the reviewed image.
name: Boundary assurance
on:
pull_request:
workflow_dispatch:
permissions:
contents: read
jobs:
verify:
runs-on: ubuntu-24.04
timeout-minutes: 20
container:
image: ${{ vars.FORMAL_VERIFICATION_IMAGE }}
env:
FORMAL_TOOLCHAIN_ID: ${{ vars.FORMAL_VERIFICATION_IMAGE }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
persist-credentials: false
- name: Verify boundaries
run: bash scripts/verify.sh
- name: Preserve evidence even on failure
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: boundary-evidence-${{ github.sha }}
path: evidence/
if-no-files-found: error
Pin action commits separately from verifier versions. Kani’s official action likewise distinguishes the action version from its kani-version input.[10] Preserve source revision, file hashes, tool and solver versions, commands, constraints, harnesses, lemmas, logs, elapsed time, counterexamples and unfinished obligations regardless of success or failure.
Cheap tests can run for everyday changes, critical Kani harnesses on PRs, Tamarin on protocol-affecting PRs and expensive exploration on a schedule. Scheduling a required proof for later does not make the current change safe. Shared parsers, key formats, policy and persistent-state changes can all affect the protocol even when its model file is untouched.
Scroll horizontally to view the complete diagram.
Read the diagram as text
Translate requirements into properties, Rust harnesses and protocol lemmas. Distinguish counterexamples, incomplete obligations and scoped evidence. Review implementation correspondence, tool versions, assumptions and bounds; feed CI and operational observations back into design.
Let verification reveal missing architecture
The example begins with one Boolean operator and a small state machine. At the protocol boundary, a signed message can still be replayed. Modeling single acceptance then creates requirements for trusted consumption state, atomicity, durability and recovery reconciliation.
Tests, fuzzing, model checking and protocol analysis need not compete. Concrete examples, symbolic inputs, attack traces and production behavior expose different failures. Retain telemetry for key access, signature failures, replay rejection and authorization denial to observe whether assumptions remain valid in operation.
The related Auth Platform PoC with Formal Verification provides attributed project context. It does not establish that the exact code, lemmas, versions or CI results in this article were delivered in that engagement.
Prefer “this authorization property over this input space” or “at most one acceptance in this protocol model under these assumptions” to “the system is formally verified.” Keep the unverified obligations visible.
Putting formal verification into the development loop means making claims and their evidence changeable and reviewable alongside the code.
References
- Rust Reference, The unsafe keyword. Declaring unsafe contracts versus satisfying their obligations.
- Kani, Tutorial and First steps. Proof harnesses, nondeterministic inputs and assertions.
- Kani, Loops, unwinding and bounds. Input bounds, loop expansion and unwinding assertions.
- Kani, Rust feature support and FAQ. Concurrency limitations, unreachable checks and
cover!. - Kani, Function contracts and Loop contracts. Experimental flags, invariants and termination obligations.
- Tamarin Manual, Cryptographic messages, Rules and Properties. Symbolic signing, linear/persistent facts and equality restrictions.
- Tamarin Manual, Modeling issues. Executability, vacuous proofs and modeling warnings.
- Tamarin Manual, First example.
--prove, summaries,--quit-on-warningand automatic/interactive proof work. - Rust stable distribution metadata, Kani 0.67.0, Kani’s pinned toolchain and Tamarin 1.12.0. Version-selection sources, not execution evidence for this example.
- Kani GitHub Action. Separate action and verifier versions with
kani-version.
Consultation dates for maintained manuals are not publication dates. The code, CI gate, SQL, figures and assurance mapping are design examples in this article.