ArticleslgStudy

engineering

Shadow stack

Shadow stack is a engineering topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Shadow stack rather than just read about it. In short: In computer security, a shadow stack is a mechanism for protecting a procedure's stored return address, such as from a stack buffer overflow or call stack spoofing. The shadow stack itself is a second, separate stack that "shadows" the program call stack.

Key takeaways

  • Shadow stack belongs to engineering; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Shadow stack to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Shadow stack from memory before moving on to harder problems.

Reference excerpt

In computer security, a shadow stack is a mechanism for protecting a procedure's stored return address, such as from a stack buffer overflow or call stack spoofing. The shadow stack itself is a second, separate stack that "shadows" the program call stack. In the function prologue, a function stores its return address to both the call stack and the shadow stack. In the function epilogue, a function loads the return address from both the call stack and the shadow stack, and then compares them. If the two records of the return address differ, then an attack is detected; the typical course of action is simply to terminate the program or alert system administrators about a possible intrusion attempt. A shadow stack is similar to stack canaries in that both mechanisms aim to maintain the control-flow integrity of the protected program by detecting attacks that tamper the stored return address by an attacker during an exploitation attempt. Shadow stacks can be implemented by recompiling programs with modified prologues and epilogues, by dynamic binary rewriting techniques to achieve the same effect, or with hardware support. Unlike the call stack, which also stores local program variables, passed arguments, spilled registers and other data, the shadow stack typically just stores a second copy of a function's return address. Shadow stacks provide more protection for return addresses than stack canaries, which rely on the secrecy of the canary value and are vulnerable to non-contiguous write attacks. Shadow stacks themselves can be protected with guard pages or with information hiding, such that an attacker would also need to locate the shadow stack to overwrite a return address stored there. Like stack canaries, shadow stacks do not protect stack data other than return addresses, and so offer incomplete protection against security vulnerabilities that result from memory safety errors. In 2016, Intel announced upcoming hardware support for shadow stacks with their Control-flow Enforcement Technology. Shadow stacks face some compatibility problems. After a program throws an exception or a longjmp occurs, the return address at the top of the shadow stack will not match return address popped from the call stack. The typical solution for this problem is to pop entries from the shadow stack until a matching return address is found, and to only terminate the program when no match is found in the shadow stack. A multithreaded program, which would have a call stack for each executing thread, would then also have a shadow stack shadowing each of the call stacks.

See also Call stack Return address Buffer overflow

References

Worked examples

Example 1 — a first encounter with Shadow stack

Start with the simplest possible case. Write down what Shadow stack claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In engineering, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Shadow stack before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Shadow stack ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Shadow stack

In research
Shadow stack appears in engineering research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Shadow stack in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Shadow stack is common in secondary-school and first-year university syllabi. It links to neighbouring topics Control flow integrity, Cybersecurity engineering, so understanding it makes those chapters shorter.
In everyday life
Look for Shadow stack outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Shadow stack in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Shadow stack means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Shadow stack out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Shadow stack in simple terms?

In computer security, a shadow stack is a mechanism for protecting a procedure's stored return address, such as from a stack buffer overflow or call stack spoofing. The shadow stack itself is a second, separate stack that "shadows" the program call stack.

Why does Shadow stack matter?

Because it connects several engineering ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Shadow stack?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Shadow stack.

Tags

  • Control flow integrity
  • Cybersecurity engineering

Keep exploring