STAMP Primer SeriesSTPA PrimerModule 2 of 3Finding Problems EarlyLesson 4 of 5Finding Problems Early, With SecurityLesson 4 of 6The Whole SeriesLesson 8 of 10

STPA Primer

A shift-by-wire car design, analyzed with each of STPA’s four steps, then with formal scenarios.

Section 2.1 · STPA Worked Example

Step 1: Losses, Hazards, and Constraints

Builds on: Section 1.2, STPA Overview: The Four Steps

A shift-by-wire gear knob with a P button on top and the letters R, N, and D lit on its face, with D selected.
On a shift-by-wire knob like this one, the letter that lights up shows the gear.

Carmakers are replacing mechanical controls with electronic ones. Braking, steering, acceleration, and gear shifting are moving to “by-wire” designs, where a control sends an electrical signal instead of moving a cable or linkage, with no mechanical backup. This example uses STPA to look for weaknesses in a shift-by-wire design, and to work out solutions.

In the design analyzed here, the shift lever springs back to the center after every shift, like a joystick. The position of the shift lever returns to center regardless of which gear it is in. From D, pushing the lever forward one click selects N, and pushing two clicks selects R. Pushing forward from R does nothing more. Park has its own P button on top of the knob. Unlike a traditional P-R-N-D lever, this lever gives the driver no way to tell the gear by looking at it or feeling where it is. Drivers can tell the gear only from a letter on the shift knob and on the dashboard.

The design has safeguards to help protect against unintended use or misuse. The engine won’t switch off unless the vehicle is in Park, and a chime sounds if the driver’s door opens when the vehicle isn’t in Park.

Step 1 starts with the losses to prevent. The system-level hazards are states of the whole vehicle that could lead to those losses, and the system-level constraints say what the vehicle must do to prevent each hazard.

Losses

  • L-1Loss of life or injury: the driver, passengers, or people nearby
  • L-2Loss of property (financial losses)

Hazards

  • H-1A vehicle is moving unattended [L-1, L-2]
  • H-2A vehicle is damaged [L-1, L-2]

What you get

System-Level Constraints

  • SC-1A vehicle must not move unattended [H-1]
  • SC-2A vehicle must not be damaged [H-2]

Section 2.2 · STPA Worked Example

Step 2: The Control Structure

The driver picks a gear with the shift lever, selects Park with the P button, and turns the engine on and off with a Start/Stop button. Software reads the lever and the buttons, and sends the commands to the transmission and the engine.

To tell what the car is doing, the driver has a letter showing the gear on the shift knob and on the dashboard, a chime if the door opens when the car isn’t in Park, and the sound of the engine.

Put together, these controls and this feedback can be sketched as a control structure, with control actions going down and feedback coming up.

Control Structure (Simplified)

DriverProcess model (beliefs)Which gear it’s in;whether the engine is runningShift lever,P button,Start/StopGear letter,Door chime,Engine soundShift and Engine ControlSoftwareEngage gear,Engage Park,Engine on/offVehicle speed,Gear engaged,Driver’s doorTransmission, Engine, and Vehicle

What you get

Constraints on the Control Structure (Examples)

  • CS-1The driver must be able to tell which gear the vehicle is in by feel or at a glance. [SC-1]
  • CS-2The driver must be able to tell whether the engine is still running. [SC-1]
  • CS-3The software shares the job of keeping a parked vehicle still, for when the driver leaves without shifting to Park. [SC-1]
  • CS-4The software must be able to tell whether the driver is still in the vehicle. [SC-1, SC-2]

Section 2.3 · STPA Worked Example

Step 3: Unsafe Control Actions

Step 2 shows what each controller can do: the driver can shift to Park, and the software can engage Park. Each of those actions is safe at some times and hazardous at others. Step 3 finds the situations where an action is unsafe and leads to the hazards in Step 1. Once they are identified, we can find ways for the system to prevent the unsafe actions or prevent the hazards if the actions happen anyway. The output of Step 3 is a set of controller constraints and the unsafe control actions they prevent.

An Unsafe Control Action (UCA) identifies the context in which a control action is unsafe. Shifting to Park, for example, is unsafe when the vehicle is moving.

The Five Parts of a UCA

UCA:

Software
Controller
provides
Type: providing
Engage Park
Control action
when the vehicle is moving
Context: what makes it unsafe
[H-2]
Hazard

UCA Context

The key part of every UCA is the context. UCAs answer the question: “When is it unsafe to <control action>, or not to?” For this software, the question is “When is it unsafe to engage Park?” Engaging Park while the vehicle is moving can damage it, so the UCA names that context and traces to hazard H-2.

How Is This Different from a Failure Mode?

A failure-based approach would focus on deviations from a required or specified behavior. A common result could be something like “Unintended shift to Park” or “Fails to shift to Park.” What do “unintended” and “fails” mean? Both are understood in terms of a required function that already tells us when it must shift to Park. Anything that departs from the defined behavior is a failure.

Suppose the software is not required to shift to Park automatically because such a function does not exist. Then the lack of automatic shifting is not considered a failure. If such a function is later added and specified, then a failure is possible and may be written. Identifying failures depends entirely on having a set of functions or requirements to start from. With STPA, the opposite is true. That’s why a UCA can’t simply say “Does not shift to Park.”

STPA can’t assume that the required functionality is known, complete, or correct, because it needs to cover non-failure cases like a missing function or an unsafe interaction between non-failed functions. We also want to be able to support early development before the functionality is fully known.

Without a known, correct function or requirement as a baseline, “Does not shift to Park” covers any moment when the shift to Park doesn’t happen. It covers driving normally down the road without shifting to Park. It also covers sitting stopped in Park without shifting to Park. In a failure-based method, “Fails to shift to Park” describes only the case where an existing function required a shift to Park and the shift didn’t happen.

STPA instead uses the concept of an unsafe control action, which is a pairing of a control action and a context in which the action is unsafe and must be prevented. Whether a control action is unsafe depends on the surrounding context, not whether it deviates from a known function or requirement. In the example above, shifting to Park is unsafe when the vehicle is moving. What could cause a UCA? It could be caused by a failure, like a function or component that doesn’t work as designed, or it could be caused by a function that was poorly conceived and hasn’t failed, a missing requirement, or an unsafe interaction between multiple functions each working as defined. The deciding factor to qualify as a UCA is whether or not it is unsafe (in terms of hazards and losses), not whether or not it deviates from a specified or required functionality.

UCA Types

There are several types of UCA. The example above is a control action provided in a context that makes it unsafe. A UCA could also describe a control action not provided in a context where an absent action is unsafe. For example, “Driver doesn’t shift to Park when exiting a vehicle that is out of Park.” In that context, the vehicle can roll away unattended and cause H-1. Without the context, “Driver doesn’t shift to Park” says little about safety and is not a UCA. The driver could be driving down the road normally, for example. The context is a necessary ingredient in every UCA.

So far, we’ve considered a control action that is provided or not provided. What about timing? A control action could be provided in the right situation but too late to prevent the hazard: the software could engage Park after the vehicle has started to roll. A control action can also be stopped too soon or applied too long: the software could keep engaging Park while the driver is trying to drive away. The table below summarizes the four types of UCA.

Type of UCAWhat it means
Not Providing Causes HazardThe control action isn’t provided in a context where it’s needed.
Providing Causes HazardThe control action is provided in a context where it’s unsafe, or with an unsafe amount, setting, or direction.
Too Early, Too Late, or Out of OrderThe control action is provided, but at an unsafe time or in an unsafe order.
Stopped Too Soon or Applied Too LongThe control action continues for too long, or stops too soon.

Putting a UCA Together

The Five Parts of a UCA

UCA:

Software
Controller
provides
Type: providing
Engage Park
Control action
when the vehicle is moving
Context: what makes it unsafe
[H-2]
Hazard

In this example, the controller (the software) and its control action (Engage Park) come straight from the control structure, and the type (provides) is one of the four UCA types above. Since the software can provide Engage Park, the UCA asks when that is unsafe: “Software provides Engage Park when ____.” Here, it’s unsafe when the vehicle is moving. The hazard it can lead to is at the end. Together, these ingredients define a UCA that should be prevented.

The table below lists more UCAs found for the driver and the software. More information is in the STPA Handbook, including UCA subcategories.

Control ActionNot Providing Causes HazardProviding Causes HazardToo Early, Too Late, or Out of OrderStopped Too Soon or Applied Too Long
Driver shifts to Park UCA-1Driver doesn’t shift to Park when exiting a vehicle that is out of Park [H-1] Not hazardous on its own: the software won’t engage Park while the vehicle is moving UCA-2Driver shifts to Park too early, before the vehicle has stopped [H-1] Not applicable: once the vehicle is in Park, subsequent Park commands from the driver have no effect
Software engages Park UCA-3Software doesn’t engage Park when the driver has left and the vehicle isn’t in Park [H-1] UCA-4Software engages Park when the vehicle is moving [H-2] UCA-5Software engages Park too late, after the vehicle has started to roll [H-1] UCA-6Software keeps engaging Park while the driver is trying to drive away [H-2]

What you get

Controller Constraints (Examples)

  • C-1The driver must shift to Park when exiting a vehicle that is out of Park. [UCA-1]
  • C-3The software must engage Park when the driver has left and the vehicle isn’t in Park. [UCA-3]
  • C-4The software must not engage Park when the vehicle is moving. [UCA-4]

Together, C-3 and C-4 mean any fix has to tell whether the driver has left or is still driving.

Section 2.4 · STPA Worked Example

Step 4: A Loss Scenario

Step 4 builds loss scenarios from the UCAs. A scenario examines the rest of the control loop, not only the action the controller took, and pieces together how several factors can combine to cause a loss. The scenario below follows the driver’s loop: what they do, what they believe, why the decision could make sense, and what feedback could support that belief.

Scenario for UCA-1

Driver3Decision making“If it’s in Park,I canstep out.”2Process modelBelieves thevehicle isin ParkUnsafe control action1UCA-1: Driver doesn’t shift to Parkwhen exiting a vehicle that isout of Park4FeedbackFelt clicks forward to an end stop,like a lever shifting to Park,Only a small letter shows the gearShift leverActuatorsShift indicationsSensorsTransmission, VehicleActually: in Reverse
  1. Unsafe control actionUCA-1: Driver doesn’t shift to Park when exiting a vehicle that is out of Park
  2. Process modelBelieves the vehicle is in Park
  3. Decision making“If it’s in Park, I can step out.”
  4. FeedbackFelt clicks forward to an end stop, like a lever shifting to Park; only a small letter shows the gear

Actually: in Reverse

The scenario: To park, the driver pushes the lever forward from D and feels it click forward multiple times until it stops at the end, the same way a traditional lever feels shifting to Park. The lever has actually selected R. The clicks and the end stop feel the way the driver expects for a Shift-to-Park maneuver, reinforcing the driver’s belief that the vehicle is in Park. The only sign of R is a small letter on the knob and the dashboard, which isn’t strong enough feedback to correct that belief. As a result, the driver gets out with the vehicle in R, and the vehicle starts to roll backward.

What you get

Requirements and Other Solutions (Examples)

Requirement

The vehicle must shift itself into Park if the driver leaves while it isn’t in Park.

Design change

Make the familiar motion for Park, pushing the lever forward until it stops, put the vehicle in Park.

Test case

Get out with the engine running in each gear, and check that the vehicle stays still.

Instructions

Check for the P and set the parking brake before getting out.

This Design Was Real

In 2016, about 811,000 cars and SUVs in the US with a shifter like this were recalled, after drivers got out believing the vehicle was in Park and it rolled away. NHTSA counted 266 crashes and 68 injuries, and no part had failed. The changes made afterward match the solutions above: “Auto Park” software, a shifter that stays in the selected gear on later models, and a reference card for owners.

STPA had already flagged this problem. At the 2016 STAMP Workshop, a month before the recall, GM engineers presented an STPA of shift-by-wire controls whose top-priority unsafe control action was a driver not putting the car in Park before getting out.

Section 2.5 · STPA Worked Example

Formal Scenarios: Four Classes for Each UCA

The scenario in the last section can be constructed informally using standard review techniques like structured brainstorming with designers and operators who understand the system. There is also a formal scenario process that builds scenarios carefully and rigorously from the UCA itself. STPA is flexible, allowing teams to decide whether to follow the informal or formal scenario development process.

STPA’s formal scenario process takes the UCA’s controller, control action, and context, and writes them into four classes of scenario. Each class looks for the problem in a different part of the control loop. Reviewers can use the formal scenario approach to evaluate the quality of the STPA work and check whether any part of the loop was skipped.

Four Classes of Formal Scenarios

Class 1Unsafe controller behavior

ControllerFeedbackGOODControlactionUNSAFEControlledprocess

The feedback is good, and the controller still provides an unsafe control action.

Class 2Unsafe feedback

ControllerFeedbackUNSAFEControlactionUNSAFEControlledprocess

The feedback doesn’t show the real situation, and the controller provides an unsafe control action.

Class 3Unsafe control path

ControllerFeedbackGOODControlactionGOODUNSAFEControlledprocess

The controller provides a good control action, and the process receives an unsafe one: changed along the control path, or sent by another controller.

Class 4Unsafe process behavior

ControllerFeedbackGOODControlactionGOODUNSAFEControlledprocess

The process receives a good control action and does something unsafe anyway.

Adapted from John Thomas, “Developing STPA Scenarios”, MIT STAMP Workshop, 2025.

The process runs in two rounds. First, the team writes the four classes for the UCA as high-level scenarios and looks for solutions that would prevent them. When those solutions aren’t enough, the team refines each class into specific causes, with and without a component failure, and looks for solutions to those. The refined scenarios can use more design detail as the design matures.

UCA-1Driver doesn’t shift to Park when exiting a vehicle that is out of Park

Underlined words come from UCA-1: its controller, control action, and context.

Scenario ClassHigh-Level Scenario, Generated From UCA-1Causes Found by Refining It
1. Unsafe controller behavior The driver doesn’t shift to Park when exiting a vehicle that is out of Park. The feedback the driver receives correctly shows that the vehicle is out of Park.
  • The driver plans to step out for a moment, to open a gate, and leaves the vehicle in Neutral, expecting it to stay still on what looks like level ground.
  • The driver has driven cars that shift into Park by themselves when the driver’s door opens, and expects this one to do the same.
2. Unsafe feedback The feedback the driver receives doesn’t adequately show that the vehicle is out of Park. The driver is exiting a vehicle that is out of Park.
  • The driver pushes the lever forward and feels it click twice and stop at the end, the way a traditional shifter feels when it’s swept up to Park. On this lever, two clicks forward from D select R, and the only sign of R is a small letter on the knob and the dashboard. This is the loss scenario drawn for Step 4. Reported to NHTSA
  • The chime and the dashboard message start only when the door opens, as the driver is already getting out. To the driver, a chime that sounds the moment the door opens seems to be about the open door, which the driver already knows about. The chime is actually warning that the vehicle is out of Park.
  • The engine sounds off after the driver presses Start/Stop, so the driver believes it is off and in Park. In reality, the idle is quiet and a safety interlock has kept it running (because the vehicle isn’t in Park). In this car the engine switches off only in Park, which reinforces the driver’s view that an engine that sounds off means the vehicle is in Park. Reported to NHTSA
3. Unsafe control path The driver shifts to Park when exiting a vehicle that is out of Park. The transmission doesn’t receive a command to shift to Park.
  • The software refuses Park and selects Neutral because the driver presses P while the vehicle is still rolling above 1.2 mph. Only the dashboard shows that Park was refused, while the shifter feels the same and looks the same (returns to center). Reported to NHTSA
  • The P button’s signal doesn’t get to the software because of a fault in the button or its wiring.
4. Unsafe process behavior The transmission receives the command to shift to Park when the driver is exiting a vehicle that is out of Park. The transmission doesn’t lock the vehicle in Park.
  • A fault in the actuator that moves the parking lock leaves the lock disengaged.
  • The parking lock engages only when it lines up with a notch in a gear, so on a slope the vehicle can roll a short way before it locks.

The four classes can be generated directly from the UCA’s wording, and they work for any unsafe control action. Each scenario class only takes a sentence or two to write.

Consider a potential requirement: the vehicle must shift itself into Park if the driver leaves while it isn’t in Park. That requirement addresses the first three classes, whatever the driver believed or pressed. The requirement doesn’t address the fourth class, unsafe process behavior, because the shift into Park still depends on the same parking lock. Writing out the fourth class points to a second way of holding the vehicle (see first item below).

What you get

Requirements and Other Solutions From the Formal Scenarios (Examples)

Design change

Apply the parking brake automatically whenever the driver leaves the vehicle, as a second hold that doesn’t depend on the parking lock.

Requirement

The vehicle must warn the driver that it isn’t in Park before the door opens, for example when the driver’s seat belt is unfastened.

Requirement

If a driver-commanded shift isn’t achieved, the driver must be notified with a chime and a message as well as the current gear on the dashboard.

Three of the causes in the table match scenarios that NHTSA later documented from drivers’ reports. Those reports came in after vehicles were on the road, when fixes cost the most. Teams don’t have to wait for those reports. STPA found scenarios like these early in design, before other manufacturers encountered these expensive problems.

STPA Found This Two Years Before the Recall

STPA work on shift-by-wire controls had already anticipated this problem, before it led to crashes, injuries, and a recall likely costing tens of millions of dollars. The work was done at a different carmaker, GM, with MIT researchers including Dr. John Thomas.

The Same Pattern Elsewhere

Other cars have misled drivers in the same way, with nothing broken:

  • With keyless ignition, drivers have walked away from cars they thought were switched off but were still running, or weren’t in Park. NHTSA proposed a rule on both risks.
  • An SUV was recalled in 2015 because its engine Start/Stop button sat among the push-button gear selectors, and people switched the engine off by mistake while driving.

The Fix May Add a Controller

Auto Park is itself a controller. Step 3 above already identified its potential UCAs, such as engaging Park when the vehicle is moving. The same Step 4 process can be used to evaluate new scenarios that may produce those UCAs. How does Auto Park know when to engage Park? The controller may use the door, the seat belt, and the brake pedal to decide whether the driver has left. The same scenario process and the same four classes will identify potential flaws and vulnerabilities related to these. For example, Class 2 asks whether the feedback could make it look like the driver is still in the vehicle after the driver has left, which would defeat the purpose of Auto Park.

Auto Park’s Control Loop (Simplified)

Auto ParkSoftware that engages ParkEngage ParkDoor open or closed,Seat belt fastened,Brake pedal pressedVehicleTransmission, door, seat belt, brake pedal
Auto Park’s unsafe control actions are in Step 3, and its loss scenarios come from the same four classes.