# Safety analysis

Safety analysis is the design-time discipline of working out how a
system can fail or cause harm, then turning that into requirements and
mitigations. It is to safety what
[threat modeling](https://quality.stereobooster.com/threat-modeling.md) is to security: a structured
analysis rather than a test. Its output supplies the **oracle** that
later verification checks the built system against — a hazard list, a
set of failure modes, a catalog of unsafe control actions. It is the
first step of [verifying safety-critical systems](https://quality.stereobooster.com/safety.md).

## What it surfaces

- **Hazards and their root causes**: the conditions that lead to harm,
  decomposed to the faults that produce them.
- **Component failure modes and their effects**: what breaks, and what
  happens downstream when it does.
- **Process and parameter deviations**: the off-nominal conditions a
  design has to tolerate or prevent.
- **Unsafe control actions**: commands (or missing commands) that move
  the system into a hazardous state without any component having
  "failed."

What it does **not** do is verify the implementation. Safety analysis
reasons about the *design*: it identifies what must not happen and what
to check. It pairs with [model checking](https://quality.stereobooster.com/model-checking.md)
of the critical logic, testing, and
[monitoring](https://quality.stereobooster.com/monitoring-and-observability.md).

## The techniques

The established techniques differ in the *direction* of their reasoning
and in what they assume causes an accident. The **failure-based**
methods (FTA, FMEA, HAZOP) treat it as one or more **component
failures**; the **systems-theoretic** method (STPA) treats it as
**unsafe control**, interactions that go wrong even when every
component works as specified.

**Fault tree analysis (FTA)** (IEC 2006)[^iec61025] reasons *top-down*: an analyst
starts from a hazard (the top event) and deductively decomposes it
through Boolean gates into the combinations of lower-level faults that
cause it, down to basic events. The *minimal cut sets* (the smallest
fault combinations that trigger the top event) are the result, and if
basic-event rates are known the top-event probability can be computed.
Open tooling exists (SCRAM, the Open-PSA model exchange format); much
of the market is commercial (Isograph, Ansys medini).

**Failure mode and effects analysis (FMEA)** (IEC 2018)[^iec60812] reasons
*bottom-up*: an analyst enumerates each component's failure modes,
traces each to its local and system effects, and rates severity,
occurrence, and detection to prioritize (the risk priority number,
RPN). It is exhaustive over single-component failures but, unlike FTA,
largely blind to the *combinations* and interactions that a fault tree
captures. Teams run it in dedicated FMEA tools, and still in
spreadsheets.

**HAZOP** (hazard and operability study) (IEC 2016)[^iec61882] is
*guideword-driven*: a team walks each design parameter against a fixed
set of guidewords (`NO`, `MORE`, `LESS`, `REVERSE`, `AS WELL AS`) to
provoke the question "what if it deviates this way?" It originated in process
and chemical engineering, where the parameters are flows, pressures,
and temperatures, and its advantage is systematic, team-based coverage
of deviations no single reviewer would enumerate.

**STPA** (system-theoretic process analysis) (Leveson 2011)[^leveson2011] reframes
safety as a *control* problem rather than a failure problem. An analyst
models the system's control structure (controllers, actuators, sensors,
the controlled process), then identifies *unsafe control actions* (a
command given when it shouldn't be, not given when it should, given too
early or too late) and the causal scenarios that produce them. Because
it does not start from component failure, it catches what the
failure-based methods structurally miss: accidents from software logic,
flawed requirements, or human operators in the loop. The open XSTAMPP
toolset supports it.

## Where it sits

The systems-theoretic model matters more as systems become
software-intensive and the dangerous behaviors emerge from interactions
rather than from the failure of any one part. The STPA-Sec variant
applies the same control model to security analysis.

Hazard analysis is a regulatory obligation: avionics (DO-178C
(RTCA 2011a)[^do178c]), automotive (ISO 26262), general electronic systems (IEC
61508), and medical-device software (IEC 62304 (IEC 2006)[^iec62304]) all require
it, with the rigor scaled to the assurance level.

## When to use, when not

**Use** it where a failure can cause physical harm and a safety regime
applies, and reach for STPA in particular on software-intensive or
human-in-the-loop systems.

**Don't** impose the full ceremony on ordinary business or web software,
where the harm from a defect is not physical and the cost is not
justified, though asking which control actions would be unsafe can
still sharpen reliability thinking there.

## Evidence

- **The systems-theoretic case.** STPA's argument for finding what the
  failure-based methods miss is definitional, not statistical:
  accidents in complex software-intensive systems often arise from
  unsafe interactions among non-failed components, which a model built
  on component failure cannot represent (Leveson 2011)[^leveson2011].
- **Provenance, not proof.** The failure-based techniques are each
  codified in an international standard
  (IEC 2006, 2018, 2016)[^iec61025] [^iec60812] [^iec61882], and the safety regimes require
  hazard analysis (RTCA 2011; IEC 2006)[^do178c] [^iec62304]. That makes them a regulatory
  obligation and the field's accepted vocabulary, not evidence that
  they outperform alternatives or each other.

## Classification

- **Quality dimensions:** Functionality: safety — design-time hazard analysis, like threat modeling — no input/oracle/guarantee axes. Safety / freedom-from-risk has no separate dimension here; it folds into Functionality (hazard-avoidance verified to an assurance level) and Reliability.
- **Area:** Safety-critical design — avionics, automotive, medical devices, rail, industrial control, energy; any system where a failure can cause physical harm, usually under a functional-safety regime (DO-178C, ISO 26262, IEC 61508, IEC 62304).

## Referenced by

- [Verifying safety-critical systems](https://quality.stereobooster.com/safety.md) · Methods

## References

[^iec61025]: IEC. 2006. *[IEC 61025: Fault Tree Analysis (FTA)](https://webstore.iec.ch/en/publication/4311)*. <https://webstore.iec.ch/en/publication/4311>.
[^iec60812]: IEC. 2018. *[IEC 60812: Failure Modes and Effects Analysis (FMEA and FMECA)](https://webstore.iec.ch/en/publication/26359)*. <https://webstore.iec.ch/en/publication/26359>.
[^iec61882]: IEC. 2016. *[IEC 61882: Hazard and Operability Studies (HAZOP Studies) — Application Guide](https://webstore.iec.ch/en/publication/24321)*. <https://webstore.iec.ch/en/publication/24321>.
[^leveson2011]: Leveson, Nancy G. 2011. *[Engineering a Safer World: Systems Thinking Applied to Safety](https://direct.mit.edu/books/oa-monograph/2908/Engineering-a-Safer-WorldSystems-Thinking-Applied)*. Engineering Systems. MIT Press. <https://doi.org/10.7551/mitpress/8179.001.0001>.
[^do178c]: RTCA. 2011a. *[DO-178C: Software Considerations in Airborne Systems and Equipment Certification](https://www.rtca.org/do-178/)*. <https://www.rtca.org/do-178/>.
[^iec62304]: IEC. 2006. *[IEC 62304: Medical Device Software — Software Life Cycle Processes](https://webstore.iec.ch/en/publication/6792)*. <https://webstore.iec.ch/en/publication/6792>.

## Acronyms

- FMEA — failure mode and effects analysis
- FTA — fault tree analysis
- HAZOP — hazard and operability study
- RPN — risk priority number
- STPA — system-theoretic process analysis
