ArticleslgStudy

computer science

JIT spraying

JIT spraying is a computer science 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 JIT spraying rather than just read about it. In short: JIT spraying is a class of computer security exploit that circumvents the protection of address space layout randomization and data execution prevention by exploiting the behavior of just-in-time compilation. It has been used to exploit the PDF format and Adobe Flash.

Key takeaways

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

Reference excerpt

JIT spraying is a class of computer security exploit that circumvents the protection of address space layout randomization and data execution prevention by exploiting the behavior of just-in-time compilation. It has been used to exploit the PDF format and Adobe Flash. A just-in-time compiler (JIT) by definition produces code as its data. Since the purpose is to produce executable data, a JIT compiler is one of the few types of programs that cannot be run in a no-executable-data environment. Because of this, JIT compilers are normally exempt from data execution prevention. A JIT spray attack does heap spraying with the generated code. To produce exploit code from JIT, an idea from Dion Blazakis is used. The input program, usually JavaScript or ActionScript, typically contains numerous constant values that can be erroneously executed as code. For example, the XOR operation could be used:

JIT then will transform bytecode to native x86 code like:

0: b8 44 33 22 11 mov $0x11223344,%eax mov eax,0x11223344 5: 35 11 22 33 44 xor $0x44332211,%eax xor eax,0x44332211 a: 35 11 22 33 44 xor $0x44332211,%eax xor eax,0x44332211

The attacker then uses a suitable bug to redirect code execution into the newly generated code. For example, a buffer overflow or use after free bug could allow the attack to modify a function pointer or return address. This causes the CPU to execute instructions in a way that was unintended by the JIT authors. The attacker is usually not even limited to the expected instruction boundaries; it is possible to jump into the middle of an intended instruction to have the CPU interpret it as something else. As with non-JIT ROP attacks, this may be enough operations to usefully take control of the computer. Continuing the above example, jumping to the second byte of the "mov" instruction results in an "inc" instruction:

1: 44 inc %esp inc esp 2: 33 22 xor (%edx),%esp xor esp,DWORD PTR [edx] 4: 11 35 11 22 33 44 adc %esi,0x44332211 adc DWORD PTR ds:0x44332211,esi a: 35 11 22 33 44 xor $0x44332211,%eax xor eax,0x44332211

x86 and x86-64 allow jumping into the middle of an instruction, but not fixed-length architectures like ARM. To protect against JIT spraying, the JIT code can be disabled or made less predictable for the attacker.

References

Worked examples

Example 1 — a first encounter with JIT spraying

Start with the simplest possible case. Write down what JIT spraying claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, 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 JIT spraying 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 JIT spraying 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 JIT spraying

In research
JIT spraying appears in computer science 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 JIT spraying 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
JIT spraying is common in secondary-school and first-year university syllabi. It links to neighbouring topics Computer jargon, Computer security exploits, so understanding it makes those chapters shorter.
In everyday life
Look for JIT spraying 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.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “JIT spraying” →

How to study JIT spraying in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what JIT spraying 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 JIT spraying out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is JIT spraying in simple terms?

JIT spraying is a class of computer security exploit that circumvents the protection of address space layout randomization and data execution prevention by exploiting the behavior of just-in-time compilation. It has been used to exploit the PDF format and Adobe Flash.

Why does JIT spraying matter?

Because it connects several computer science 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 JIT spraying?

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 JIT spraying.

Tags

  • Computer jargon
  • Computer security exploits

Keep exploring