# Replay Attacks

> Understanding how attackers attempt to reuse trusted client signals and why modern protection requires dynamic execution, environmental consistency, and layered detection.

---

## Overview

Replay attacks occur when an attacker captures a previously valid response, token, cookie, or client-generated signal and attempts to reuse it outside the original context.

In web security and advertising protection, replay attacks are particularly relevant because many detection systems rely on client-side signals generated by JavaScript execution.

If an attacker can capture and reproduce those signals, they may attempt to make automated traffic appear as if it originated from a legitimate browser environment.

The challenge is not only preventing copied values from being reused.

The challenge is ensuring that trusted signals remain connected to the environment and behaviour that produced them.

---

# Why Client-Side Signals Are Targeted

Browser intelligence provides valuable information about the actual client environment.

Examples include:

* browser characteristics
* JavaScript execution behaviour
* device properties
* rendering signals
* environment consistency

However, any client-side mechanism can become a target.

Attackers may attempt to:

* observe client execution,
* understand what signals are collected,
* reproduce expected values,
* automate the generation of valid-looking responses.

The security value of a client-side signal depends on how difficult it is to understand, reproduce, and scale.

---

# Attacker Workflow

Replay-based attacks typically involve several stages.

```text id="m7n8q4"
Observation
    ↓
Extraction
    ↓
Analysis
    ↓
Emulation
    ↓
Scaling
```

---

## Observation

Attackers first study how a browser interacts with a protected application.

They may observe:

* network requests
* client-generated values
* cookies
* browser behaviour
* JavaScript execution

The goal is understanding which information influences trust decisions.

---

## Extraction

Client-side code and generated responses may be inspected.

Attackers may attempt to identify:

* how values are generated
* which browser properties are accessed
* what data is sent back to the server

Static client-side logic is particularly valuable to attackers because it can be studied repeatedly.

---

## Analysis

After extraction, attackers may analyze client behaviour to understand:

* required inputs
* expected outputs
* relationships between signals
* environmental assumptions

This may involve instrumentation and controlled analysis of the execution environment.

---

## Emulation

Once attackers understand enough of the process, they may attempt to reproduce the required environment.

Different approaches create different detection challenges.

---

# Browser Automation Replay

A common approach is modifying existing browser automation frameworks.

Automation systems may attempt to reproduce:

* browser APIs
* JavaScript properties
* user interactions
* expected client responses

Some automation approaches modify browser-visible behaviour through JavaScript-level changes.

These modifications can introduce inconsistencies because a browser that claims to be a normal user environment may expose unexpected implementation details.

Examples of potential inconsistencies include:

* altered browser APIs
* unusual property behaviour
* mismatched environment characteristics

---

# Custom Browser Environments

More advanced attackers may avoid JavaScript-level modification by using customized browser builds.

A modified browser can potentially produce a more consistent client-side environment because changes are made deeper in the browser stack.

In these cases, simple automation indicators become less useful.

Detection must rely more heavily on:

* environment consistency
* protocol behaviour
* network intelligence
* behavioural patterns

This is why no single browser signal should be treated as sufficient.

---

# Request Bot Replay

Not all attackers attempt to run a full browser.

Advanced request bots may attempt to reproduce trusted interactions by:

* understanding client-side logic,
* reproducing required values,
* executing client logic in controlled environments.

The challenge for these systems is maintaining consistency between:

* the generated response,
* the environment that produced it,
* the network source,
* subsequent activity.

A valid response generated in one context may become suspicious when used in another.

---

# Why Static Challenges Become Weaker

Static challenges create predictable targets.

If the same client-side logic and expected outputs remain unchanged over time, attackers may eventually:

* understand the process,
* automate the response,
* replay captured results.

This does not mean client-side challenges are ineffective.

It means that security-sensitive client logic benefits from being:

* dynamic,
* difficult to analyze,
* resistant to extraction,
* tied to the execution environment.

---

# Dynamic Execution and Replay Resistance

Ad Protect uses an obfuscated JavaScript layer based on a custom dynamically compiled virtual machine (VM).

The purpose is to increase resistance against:

* static analysis,
* extraction,
* automated reproduction,
* replay attempts.

A dynamically compiled execution environment makes it more difficult for attackers to create a simple reusable implementation of the client logic.

The goal is not to make analysis impossible.

The goal is to increase attacker cost and reduce the scalability of automated abuse.

---

# Environmental Binding

Replay resistance depends on more than protecting the JavaScript code.

A trusted signal should remain connected to the environment that generated it.

Important consistency relationships include:

* browser environment
* device characteristics
* network context
* protocol behaviour
* observed activity patterns

A replayed response may become suspicious if the surrounding conditions do not match.

Examples:

* a client response generated from one browser environment appearing from another,
* a browser signal appearing alongside inconsistent protocol characteristics,
* a trusted interaction followed by abnormal activity patterns.

---

# Replay Attacks and the Four Detection Layers

Replay resistance is strongest when combined with layered analysis.

## Layer 1: Network Intelligence

Validates:

* source infrastructure
* IP reputation
* proxy indicators
* network consistency

---

## Layer 2: Protocol Intelligence

Validates:

* HTTP characteristics
* TLS fingerprints
* communication patterns

---

## Layer 3: Browser Intelligence

Validates:

* browser environment
* JavaScript execution
* fingerprint consistency
* client-side signals

---

## Layer 4: Behavioural Intelligence

Validates:

* interaction patterns
* clustered activity
* click behaviour
* session consistency

---

# Key Takeaways

* Replay attacks attempt to reuse trusted client signals outside their original context.
* Client-side security mechanisms must assume attackers will attempt analysis and reproduction.
* Static challenges become weaker when they can be studied and automated.
* Dynamic execution increases the difficulty of extraction and replay.
* A generated token or cookie is more valuable when tied to the environment that produced it.
* Custom browser environments can bypass simple automation checks, requiring deeper consistency analysis.
* Strong protection requires correlation across network, protocol, browser, and behavioural intelligence.

---

# Related Documentation

* `bot-detection.md`
* `browser-fingerprinting.md`
* `canvas-fingerprinting.md`
* `traffic-classification.md`
* `trust-and-false-positives.md`
* `automation-analytics.md`
