Getting Started with Shifa
What is Shifa?
Shifa is a static analysis tool for C programs that combines Separation Logic (for memory safety) with Information Flow Analysis (for security properties). It uses Z3 as its SMT solver backend.
Unlike dynamic tools (sanitizers, fuzzing), Shifa reasons about all execution paths statically, providing formal guarantees about information flow.
Security Levels
Shifa uses a two-level security lattice:
- Hi (High / Secret) — confidential data that must not leak
- Lo (Low / Public) — data that may be publicly observable
The core property: information must never flow from Hi to Lo. Shifa detects both explicit flows (direct assignment) and implicit flows (information leaked through branch conditions).
You can define custom labels that map to this lattice using
lattice Lo_name <= Hi_name;. For example,
lattice Trusted <= Untrusted; for privilege isolation, or
lattice Public <= Secret; for data classification.
How to Use the Playground
- Pick a demo from the dropdown, or write your own C code in the editor.
- Write stubs in the right editor to declare security levels for function parameters and global variables.
- Set the entry function — Shifa analyzes starting from this function.
- Choose a mode:
- IFA — Information Flow Analysis (detects Hi→Lo leaks)
- CT — Constant-Time analysis (detects secret-dependent branches and array indices)
- MS — Memory Safety only (separation logic, no security)
- Click Run Analysis and inspect the output.
Understanding the Output
In IFA mode, look for:
LEAK— a Hi value flows to a Lo sink (violation!)LEAK [Integrity]— untrusted (Hi) data written to protected (Lo) resourceLEAK [SecretRemnant]— secret data not erased beforefree()ReturnHi— function returns Hi when spec says LoOK— no security violation found
In CT mode, additionally:
[VIOLATION] BranchCond— secret-dependent branch (timing leak)[PROTECTED] ArrayIndex— secret array index (cache side channel)[REPAIRED]— violation mechanically repaired by CT transformer
Example: Detecting a Secret Leak
Consider a password checker:
int check(int secret, int guess) {
if (secret == guess)
return 1;
else
return 0;
}
With the stub spec check(Hi, Lo) -> Lo;, Shifa detects that the return
value depends on the Hi branch condition — an implicit flow violation.
Try the Demos
Start with the curated demos in the dropdown. Each one demonstrates a different analysis capability:
- Basic Information Flow — simple function call chains
- PQC Key Handling — mixed-security array regions (safe vs. leak)
- Implicit Flow — information leaked through branches
- Parallel Tenants — pthread-based multi-tenant isolation
- Constant-Time — detecting timing side channels
- Memory Safety — separation logic verification (swap, use-after-free)
- Secret Remnant — secret data not erased before free
- Privilege / Integrity — Biba dual with custom lattice labels
- Custom Lattice — domain-specific security labels
- Syscall APIs — 7-function kernel-user isolation system (insecure vs. secure vs. user-space)