How-to guides › Analyse safety and security

How-to guides

Safety and cybersecurity: STPA, error propagation, TARA

archec makes the safety analysis and the cybersecurity analysis from the model. For safety, it derives fault trees and an FMEA from the errors each part makes and passes on, and it checks an STPA against the architecture. For security, it rates threats as ISO/SAE 21434 does, in a TARA (threat analysis and risk assessment).

A first fault tree#

Two speed sensors feed a controller, and the controller commands the brakes. Each sensor can go silent. The controller stops braking only when both are silent:

message SPEED "Wheel speed": float32
message CMD "Brake command": float32

component Sensor "Speed sensor" {
  out speed: can sends SPEED { produces omission }
}
component Ctrl "Controller" {
  in left:  can receives SPEED
  in right: can receives SPEED
  out cmd:  can sends CMD { from-all left, right }
}
component Brake "Brake" {
  in cmd: can receives CMD
}

system Car "Car" {
  part s1:     Sensor
  part s2:     Sensor
  part ctrl:   Ctrl
  part brakes: Brake
  s1.speed -> ctrl.left
  s2.speed -> ctrl.right
  ctrl.cmd -> brakes.cmd
}

failure-mode FM-S1 "Sensor 1 dead" { of Car.s1; produces omission; probability 1e-5 }
failure-mode FM-S2 "Sensor 2 dead" { of Car.s2; produces omission; probability 1e-5 }

hazard HZ-01 "No braking" {
  severity S1
  exposure E2
  controllability C2
  error omission on Car.brakes.cmd
}
Diagram: Car
What archec draws from this code: Car
Try it
archec safety main.arche
Hazards
Id          ASIL  Written (/h)  Derived (/h)  Event
HZ-01       QM    —             1.00e-10      No braking

Fault trees, derived from the error model
HZ-01 No braking — omission on Car.brakes.cmd  1.00e-10 /h
  omission at Car.ctrl.cmd  1.00e-10 /h
    omission on every one of left, right (Car.ctrl) (AND)  1.00e-10 /h
      omission at Car.s1.speed  1.00e-5 /h
        FM-S1 Sensor 1 dead  1.00e-5 /h
      omission at Car.s2.speed  1.00e-5 /h
        FM-S2 Sensor 2 dead  1.00e-5 /h
  minimal cut sets: {FM-S1 + FM-S2}

FMEA, derived from the error model
Source                Of                    Error       Hazards       Reaches
FM-S1                 Car.s1.speed          omission    HZ-01         omission at Car.brakes.cmd
FM-S2                 Car.s2.speed          omission    HZ-01         omission at Car.brakes.cmd

Nobody wrote this fault tree: archec followed the error from each sensor, over the links, to the brakes. A minimal cut set is a smallest set of failures that together cause the hazard. Here both sensors must fail.

Safety: error propagation and STPA#

Error propagation#

Each part says which errors it makes, and what happens to the errors that reach it. The links carry the errors from part to part. This is the idea of AADL's error model annex.

component Sensor { out speed: can sends SPEED { produces omission, value } }
component Ctrl {
  in left: can receives SPEED { contains late; turns value into omission }
  in right: can receives SPEED { turns value into omission }
  out cmd: can sends CMD { from-all left, right }   // redundant: both must fail
}
failure-mode FM-S1 "Sensor 1 dead" { of Car.s1; produces omission; probability 1e-5 }
hazard HZ-01 "No braking on demand" { …; error omission on Car.brakes.cmd; caused-by FM-CTRL, G-SENSORS }
  • Error types. There are five: omission, commission, value, early and late.
  • Sources. produces on an output makes it an error source. A failure-mode with of and produces gives that source a rate, with probability.
  • Inputs. contains on an input stops errors of that type. contains all stops every type. turns a into b changes an error's type.
  • Outputs. By default an output passes on the errors of every input. from names the inputs it takes errors from. from-all is an AND: the output fails only when all the inputs it names fail.

What archec derives:

  • A fault tree per hazard. Each hazard that says error … on … gets a fault tree, its minimal cut sets and its rate. The rate is 1 − ∏(1 − ∏ p) over the cut sets.
  • An FMEA row per error source. The row says where the error goes and the hazards it leads to.
  • They are marked derived in archec safety, in the LaTeX and HTML specification, and in the editor.

What archec checks:

  • fta-mismatch: a fault tree written by hand (caused-by, gates) has other cut sets than the derived one.
  • fmea-mismatch: a failure mode's causes are not the hazards its error reaches.
  • error-unreached: no error reaches a hazard.
  • Unknown error types.

STPA#

STPA is Leveson's analysis, written here as Gaphor's RAAML writes it. It uses the architecture as its control structure. A control action goes from a controller part to the part it controls, over the links. Feedback comes back the other way.

control-action CA-BRAKE "Apply the brakes" {
  from Car.adcu
  to Car.brakes
  carries BRAKE_CMD
  feedback WHEEL_SPEED
  not-applicable duration
  because "The brakes release on their own when the command stops."
  uca UCA-1 "No braking with an obstacle ahead" {
    type not-provided
    causes HZ-01
    constraint REQ-SAF-1
    loss-scenario LS-1 "The radar misses it in heavy rain" { factor feedback; constraint REQ-SAF-2 }
  }
}

A UCA (unsafe control action) is one of four types:

  • not-provided: the action is not given when it is needed;
  • provided: the action is given, and that causes a hazard;
  • timing: too early, too late, or out of order;
  • duration: stopped too soon, or applied too long.

What archec checks:

  • stpa-incomplete: each control action is considered for the four types, or the type is marked not-applicable.
  • uca-untraced: each UCA leads to a hazard, and a constraint (a requirement) prevents it.
  • stpa-no-path: a link carries the action from the controller to the process it controls, and a link carries the feedback back.
  • A hint: a UCA with no loss scenario.

The report#

archec safety main.arche [--json] prints:

  • the hazards;
  • the derived fault trees and FMEA;
  • the STPA tables.

It exits with 1 on a mismatch or an STPA gap. The LaTeX and HTML specification show the same in their Safety section. The editor shows them in the model tree, under Safety.

Cybersecurity (TARA)#

A TARA follows ISO/SAE 21434. It sits next to the safety analysis:

message BRAKE_CMD "Brake command" { force: float32 }

component Adcu "Driving computer" {
  out can_brake: can sends BRAKE_CMD
}
component Brakes "Brakes" {
  in can: can receives BRAKE_CMD
}

system Car "Car" {
  part adcu:   Adcu
  part brakes: Brakes
  adcu.can_brake -> brakes.can
}

asset AS-BRAKE "Brake commands" { of Car.adcu.can_brake; properties integrity }
damage-scenario DS-BRAKE "Full braking on the motorway" { asset AS-BRAKE; property integrity; safety severe }
threat TS-SPOOF "Spoofed brake commands" { damages DS-BRAKE; stride spoofing; vector adjacent; treatment reduce; goal CSG-01 }
attack-path AP-OBD "From the OBD port" { threat TS-SPOOF; elapsed week; expertise proficient; knowledge restricted; window moderate; equipment standard }
security-goal CSG-01 "Brake commands are authentic" { text "The brakes shall act only on authentic brake commands."; answers TS-SPOOF }
Diagram: Car
What archec draws from this code: Car
Try it
archec tara main.arche
Threat        Impact      Feasibility     Risk  CAL   Treatment  Goals
TS-SPOOF      severe      medium (11)     4     CAL4  reduce     CSG-01

1 threat(s), 1 with risk 4 or 5: TS-SPOOF

A threat can also name the bus it goes through, with via Car.chassis_can.

How the figures are made:

  • Feasibility of an attack path comes from its attack-potential points (annex G of the standard): 0–9 is high, 10–13 medium, 14–19 low, 20 and more very low. A threat takes the feasibility of its easiest path.
  • Impact is the worst rating of what the threat damages.
  • Risk (1 to 5) comes from the impact and the feasibility.
  • CAL (cybersecurity assurance level) comes from the impact and the attack vector.
  • Risk and CAL use the standard's example tables.

What archec checks (security-risk, cal-too-low, tara-incomplete):

  • a risk of 4 or 5 with no treatment;
  • reduce with no security goal;
  • retain or share with no claim;
  • a goal whose CAL is lower than its threats need;
  • attack paths and damage scenarios that are not rated.

archec tara main.arche [--json] prints the table. It exits with 1 on an untreated risk of 4 or 5. The LaTeX specification has a TARA section.

Limits#

  • The derived fault trees follow the error model as it is written. An error path the model does not write (a part, a link or a failure mode left out) is not in them.
  • The rates are only as good as the probability of each failure mode. A source that no failure mode rates is a basic event with no rate.
  • In the Arche project, only hazard and safety-goal are written (safety.yaml). failure-mode and gate are checked and typeset, but not written.
  • Security goals are written to Arche as requirements of category security. The rest of the TARA stays in archec: Arche has no place for it yet.
  • Risk and CAL use the example tables of ISO/SAE 21434. A project with its own tables must check the figures against them.