Risk scoring and explanations
Tirith turns analysis findings into a deterministic risk score and a set of explanations that people and tools can inspect. The score summarizes signal strength and overlap. The explanations preserve the reason for each finding and guide the next safe action. This page complements Command safety engine, Rule detection system, and Policy and verdict decisions.
Scoring model
A finding is a signal produced by a detection rule. The scoring model uses the findings in a verdict and applies fixed, named factors rather than a learned model. This makes the result reproducible and keeps the score separate from the enforcement decision.
Score factors
The score starts with the highest severity. It then adds weight for independent findings and for threat-intelligence support when that support confirms another substantive signal.
| Factor | Contribution | Purpose |
|---|---|---|
| Highest-severity finding | Critical 90, High 70, Medium 40, Low 15, Info 0 | Sets the score floor from the strongest signal. |
| Additional findings | 5 for each substantive finding after the first | Shows that several signals support the same risk assessment. |
| Threat-intelligence corroboration | 5 | Rewards a local threat-database hit that appears with another substantive finding. A lone threat hit does not receive this extra factor. |
| Score cap | Negative adjustment when needed | Caps the final score at 100 while keeping the factor total exact. |
Info findings that only describe command-card, manifest, or paste metadata do not count as substantive findings. If policy promotes one of these notes above Info, it becomes a risk signal and counts. This prevents useful context from inflating risk while still respecting an explicit policy choice.
Every breakdown contains a factor label, point value, and plain-language detail. Its factors must sum to the final score, including any score-cap adjustment. References: crates/…/scoring.rs• L1-17, crates/…/scoring.rs• L369-405, crates/…/scoring.rs• L417-518
Risk levels
The numeric score maps to a fixed risk-level bucket. The bucket helps a person read the result but does not replace the underlying findings.
| Score | Risk level |
|---|---|
| 0–20 | low |
| 21–50 | medium |
| 51–75 | high |
| 76–100 | critical |
The score is advisory. It does not change the verdict action, exit code, or audit record. A High or Critical finding can block a command even when the aggregate score does not add useful context, and a low score does not make a policy block disappear. References: crates/…/scoring.rs• L407-415, crates/…/scoring.rs• L13-16, crates/…/verdict.rs• L1035-1063
Policy tuning
Policy tuning changes how a signal is treated before it reaches the final verdict and score. The main controls are severity overrides, action overrides, paranoia filtering, and time-boxed rule metadata. These controls tune the system without changing the rule's identity or its explanation.
Severity overrides
severity_overrides maps a snake-case rule ID to a new severity. The override is applied before action derivation, so it can raise or lower the action that follows and can also change the score's base severity or finding count.
The policy exposes one shared severity lookup for analysis, static scans, installation checks, session warnings, and scoring. Rules that protect integrity, reputation, or known-malicious supply-chain content have a High floor. A policy can raise those rules to Critical, but it cannot lower them below High. Unknown rule IDs fail policy validation rather than silently creating a control that does nothing. References: crates/…/policy.rs• L2383-2407, crates/…/policy_validate.rs• L116-127, crates/…/verdict.rs• L888-908
Action overrides and paranoia
An action_overrides entry can force a named rule to Block. It is an enforcement control, not a score weight. Action overrides are checked before paranoia filtering, and a forced Block keeps the finding that explains the block even if the selected paranoia level would hide that finding from normal output.
Paranoia controls which lower-severity findings remain visible after detection. Levels 1 and 2 keep Medium and above. Level 3 also keeps Low. Level 4 also keeps Info. The engine still detects all signals; filtering changes the output set and recalculates the ordinary action from that set. References: crates/…/escalation.rs• L286-360, crates/…/engine.rs• L3279-3317, crates/…/policy_validate.rs• L652-680
Rule metadata
Rule metadata is separate from rule explanations. It describes early-access licensing gates for a rule, including the minimum tier and an exclusive end date. During an active gate, findings below the required tier are suppressed, while Critical findings always pass through. A missing or malformed gate entry fails open so a date error cannot hide a rule forever.
The current early-access metadata table has no active entries. The distinction remains important: metadata controls availability, while severity and score describe risk and the explanation record describes meaning. References: crates/…/rule_metadata.rs• L1-25, crates/…/rule_metadata.rs• L27-87
Event correlation
Some risks only become clear when separate events occur in sequence. Event correlation means matching typed events in a bounded session history, such as a secret-bearing write followed by network egress. These correlations produce findings with their own rule IDs and severities, so they enter the same verdict and scoring path as direct detections.
Correlation windows
The correlation engine evaluates ordered event pairs or short event bursts inside fixed time windows:
| Correlation | Window and condition | Severity |
|---|---|---|
| Secret write then network | Secret-bearing file write followed by network egress within 30 seconds | Critical |
| Dependency change then network | Dependency manifest change followed by network egress within 60 seconds | Medium |
| Delete then force-push | File deletion followed by git push --force within 60 seconds | Critical |
| Mass file deletion | At least three non-build files deleted within 20 seconds | Critical |
The event record keeps coarse event type and context such as path or host. The correlation result includes a description of the matched sequence and a stable signature for that exact match. Build artifacts do not count toward the mass-deletion threshold.
The current command is provisional during pre-execution checks. Tirith uses it to decide whether the sequence should block, but it does not save the event until a trusted caller confirms execution. This prevents a denied command from poisoning later session history. References: crates/…/event_buffer.rs• L1-14, crates/…/event_buffer.rs• L247-277, crates/…/event_buffer.rs• L530-701, crates/…/escalation.rs• L786-834
Correlation presentation
Session history is bounded, and surfaced correlations are de-duplicated while their source events remain live. Enforcement still sees every matching hit, even when the same hit was already shown as a warning. This split prevents presentation de-duplication from weakening a later blocking decision.
When event provenance is confirmed, the explanation states that the events ran. When provenance is provisional or unresolved, the explanation uses observation language and says that enforcement is conservative. Session warning records apply the same severity override as the verdict, so warnings and verdicts do not disagree about a tuned correlation rule. References: crates/…/event_buffer.rs• L64-79, crates/…/event_buffer.rs• L364-390, crates/…/session_warnings.rs• L617-640, crates/…/session_warnings.rs• L682-778
Explanation records
Each rule has a stable explanation record. The record gives a rule ID, title, category, severity rationale, description, flagged and safe examples, false-positive guidance, remediation, optional MITRE ATT&CK data, and external references. This gives operators a consistent meaning for a finding instead of requiring them to infer intent from a pattern name.
Explanation data
The TOML rule catalog is the source for the explanation records. The build step checks that every RuleId has exactly one entry and that every category is valid. It then makes the records available for lookup by rule ID or category, and generates shared remediation and MITRE lookups.
This completeness check is a contract between detection and explanation. Adding a rule without adding its explanation is a build failure, while an explanation for an unknown rule is also rejected. The explanation module also checks that authored prose survives mandatory sensitive-value redaction, so built-in guidance is not mangled when it is rendered. References: crates/…/rule_explanations.toml• L1-9, crates/…/rule_explanations.rs• L1-62, crates/…/rule_explanations.rs• L105-145, crates/…/build.rs• L1438-1477, crates/…/build.rs• L1518-1607
Human-readable guidance
The explain workflow can show one rule, list rules by category, resolve a rule from an audit finding ID, or show only its remediation. A finding ID uses an event ID and finding index. Resolution searches a bounded recent part of the audit log and reports when older history was not searched, so operators can narrow the audit query before requesting the rule explanation.
Human output presents the severity rationale, meaning, examples, false-positive guidance, remediation, and any MITRE or reference links. The --fix view narrows this to the rule identity and remediation. JSON exposes the same selected record or view for tools, while unknown rule and category inputs return a clear error and can suggest a close rule ID.
Finding output also attaches the canonical remediation for the finding's rule. Human verdict output renders the finding description, evidence, and remediation after sanitizing untrusted text. A rule's remediation is guidance; it does not silently rewrite or approve the command. References: crates/…/explain.rs• L6-39, crates/…/explain.rs• L41-115, crates/…/explain.rs• L118-189, crates/…/explain.rs• L192-275, crates/…/output.rs• L17-37, crates/…/output.rs• L141-218
Machine-readable reporting
The score command returns the score, risk level, and findings. With --explain, it also returns the complete factor breakdown so a consumer can reproduce the total. SARIF uses the rule explanation to populate full descriptions, MITRE tags, and help links when a matching explanation exists. Custom rules retain their effective custom ID so separate custom rules remain separate in SARIF.
These reporting surfaces share stable rule IDs and explanation fields, but they serve different needs: score output summarizes risk, verdict output supports execution feedback, and SARIF supports external analysis tools. References: crates/…/score.rs• L7-42, crates/…/score.rs• L44-72, crates/…/sarif.rs• L6-55
Blast-radius analysis
Blast-radius analysis estimates how far a destructive filesystem command may reach. It separates fast string-shape checks from a bounded filesystem simulation, so the execution hot path can flag obvious hazards while tirith preview can estimate concrete impact.
Cheap destructive checks
The cheap check does not access the filesystem or expand globs. It flags broad system paths, empty-variable paths that may collapse to the filesystem root, find -delete, and rsync --delete. It also reports incomplete analysis when a destructive operation is hidden behind bounded nested-command or command-normalization work.
An environment variable that is absent from Tirith's snapshot is advisory because it may be a shell-local value that Tirith cannot see. A variable that is present and empty is an unambiguous root-collapse case and receives the stronger signal. References: crates/…/blast_radius.rs• L189-250, crates/…/blast_radius.rs• L254-395, crates/…/blast_radius.rs• L791-845
Preview simulation
The preview simulator resolves targets against the working directory, expands one directory level of glob components, and counts files, directories, and symlinks. It checks repository and system-path boundaries before walking and never follows symlinks. The report records glob matches, the largest file, traversal errors, and whether destructive targets remain unclassified.
All traversal work shares a cap of 100,000 operations and a maximum depth of five. Directory reads, entries, metadata checks, glob candidates, and filesystem errors consume the same budget. A cap or read error makes counts lower bounds and marks classification incomplete instead of presenting partial coverage as a complete result. References: crates/…/blast_radius.rs• L23-76, crates/…/blast_radius.rs• L402-508, crates/…/blast_radius.rs• L1061-1197, crates/…/blast_radius.rs• L1367-1464
Blast-radius findings
The simulator emits findings for repository escape, system paths, symlink presence, large file counts, and incomplete classification. A large file count is informational. Incomplete classification is a safety signal because unexamined targets cannot be proven safe.
The repository boundary check combines lexical path cleanup with filesystem resolution when symlink components exist. This catches a path that looks inside the repository but reaches outside through an intermediate symlink, while allowing a symlink that resolves to a location still inside the repository. References: crates/…/blast_radius.rs• L511-584, crates/…/blast_radius.rs• L1266-1343
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the severity values, risk-level thresholds, factor labels, and breakdown invariant aligned between scoring.rs and the score CLI's human and JSON output.
- When adding or renaming a
RuleId, update the explanation catalog and the generated lookup contract. A missing or duplicate explanation must fail the build. - When changing severity override behavior, check direct verdicts, static scan verdicts, session warnings, correlation findings, and score counting. They must all use the same effective severity.
- When changing correlation event kinds or windows, keep event derivation, provisional enforcement, confirmed-event persistence, stable signatures, and warning de-duplication in agreement.
- When changing blast-radius limits or path rules, keep cheap checks, preview fields, incomplete-classification handling, and finding generation consistent.
- When changing finding fields or remediation data, check the JSON finding view, human output, SARIF descriptors, and redaction boundaries together.
- When changing finding ID format or audit lookup limits, keep audit records,
RuleIdparsing, bounded-history errors, and the human and JSONexplainviews aligned.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
A new RuleId has no explanation entry | The build rejects the catalog instead of shipping an undocumented finding. | The explanation compiler checks both directions between rule IDs and catalog entries. |
| A note-only Info finding is counted as substantive | Metadata inflates the score or falsely corroborates a threat hit. | The scorer excludes defined note-only rules at Info and counts them after policy promotion. |
| Raw score factors exceed 100 without a cap record | The displayed score and its explanation do not reconcile. | The scorer adds a negative clamp factor so all factors still sum to the final score. |
| A low severity is configured for an integrity or known-malicious rule | A dangerous finding could become a warning and allow unsafe bytes to proceed. | The shared severity lookup enforces a High floor. |
| A denied provisional command is persisted as executed history | Later correlation can report a sequence that never ran. | Correlation checks provisional events before execution but persists them only after confirmation. |
| Presentation de-duplication suppresses an enforcement hit | A repeated critical sequence may fail to block on retry. | Enforcement receives all matching hits; de-duplication is limited to warning presentation. |
A finding is outside the bounded audit tail used by explain --finding | The rule cannot be resolved from that command, even though the audit record may exist farther back. | The command reports that older history was not searched and directs the operator to a narrower audit export. |
| A preview work cap or read error leaves targets unclassified | Partial counts can be mistaken for a complete safety result. | The report marks incomplete classification and emits analysis_incomplete. |
| A repository path crosses an intermediate symlink | Lexical containment can miss an outside target. | Existing symlink components are resolved before the repository boundary decision. |
Key files
| File | Why to read it |
|---|---|
| crates/…/scoring.rs | Defines the score factors, risk buckets, note exclusions, threat corroboration, and factor-sum invariant. |
| crates/…/verdict.rs | Defines rule IDs, severities, findings, actions, and the base action mapping used beside scoring. |
| crates/…/policy.rs | Defines severity override lookup and its safety floor across policy consumers. |
| crates/…/escalation.rs | Shows static verdict finalization, action overrides, paranoia interaction, and provisional correlation flow. |
| crates/…/rule_metadata.rs | Defines early-access metadata and tier-based finding filtering. |
| crates/…/rule_explanations.rs | Provides the stable explanation and remediation lookup interface. |
| crates/…/rule_explanations.toml | Holds the human-facing source data for every rule explanation. |
| crates/…/build.rs | Enforces explanation completeness and generates shared explanation lookups. |
| crates/…/event_buffer.rs | Defines typed session events, correlation windows, correlation findings, and stable match signatures. |
| crates/…/session_warnings.rs | Connects correlation results to bounded session history and warning presentation. |
| crates/…/blast_radius.rs | Defines cheap destructive checks, preview simulation, path boundaries, and incomplete coverage signals. |
| crates/…/score.rs | Shows score and breakdown output for human and machine consumers. |
| crates/…/explain.rs | Shows rule explanation, category listing, bounded finding lookup, remediation-only views, and JSON or human output. |
| crates/…/output.rs and crates/…/sarif.rs | Show how explanations and findings are rendered for terminal and SARIF consumers. |