Skip to content
Tutorials Center
My learning

Topics

Lesson 24 of 38 ยท Authentication and Sessions Testing

Session Token Analysis with Sequencer

Learn why session tokens must be unpredictable, how Burp Sequencer measures randomness with entropy tests, and how to build a small entropy estimator in Python.

After you log in, a website does not ask for your password on every click. It gives your browser a session token, usually in a cookie, and recognises you by it. Whoever holds that token is you as far as the server is concerned. So the token must be impossible to guess. If an attacker can predict the next token, they can walk into someone else's session without any password.

Burp Sequencer is the tool that tests how random a set of tokens is. In this lesson you learn what it measures, how to use it, and how to read its verdict. Burp is a desktop app and cannot run in the browser here, so the Sequencer screens are labelled example output, while the Python blocks are stand-ins that compute similar statistics on data generated locally.

What makes a good token

A secure session identifier should be:

  • Long enough: at least 128 bits of space (for example 16 random bytes).
  • Generated by a cryptographically secure random generator, not by time, counters or rand().
  • Opaque: no embedded user name, role or timestamp an attacker could forge.
  • Rotated on login and logout, and invalidated on the server side.

Common weak designs are easy to spot in a list of tokens:

Design Example sequence Problem
Incrementing counter 1001, 1002, 1003 Trivially predictable
Timestamp-based 1731412345001 Guessable window
Encoded username dXNlcj1hbGljZQ== (Base64 of user=alice) Forgeable
Short random 4 hex digits Only 65,536 possibilities

How Sequencer works

Sequencer needs a live capture or a loaded list of tokens, collected by repeating the request that issues a token (for example a login) many times. It then runs statistical tests.

  1. In Proxy history or Repeater, find a response that sets the token (Set-Cookie: sid=...).
  2. Right-click and choose Send to Sequencer.
  3. In the Sequencer tab, pick the token location (a cookie, a form field, or a custom selection).
  4. Click Start live capture. Burp resends the request and extracts the token each time.
  5. Aim for at least 100 samples to get any analysis, and thousands for confident results (the tool's guidance is around 10,000 for a final judgement).
  6. Press Analyze now.

Only do this against an application you are authorised to test, and note that thousands of logins may trigger rate limiting or lock your test account.

Reading the result

Sequencer reports an overall result such as Excellent, Reasonable or Poor, and an estimated number of bits of effective entropy. Example output (labelled example):

TEXT
Overall result: The entropy of the sample is estimated to be 31 bits.
  Effective entropy at 1% significance level:   31 bits
  Character-level analysis:   position 1..8 hex digits; positions 5-8 poor
  Bit-level analysis:         62 of 128 bits failed FIPS monobit test
Conclusion: tokens are NOT sufficiently random for session identifiers.

Sequencer applies several tests: a character-level and bit-level analysis, the FIPS 140-2 style tests (monobit, poker, runs, long runs), compression, correlation and spectral tests. You do not need to compute them by hand, but you should understand what they ask.

Entropy in plain terms

Entropy measures unpredictability in bits. A token drawn uniformly from 2^64 possibilities has 64 bits. If the first half of a token is always the same, the effective entropy is only the half that varies, whatever the nominal length.

Estimate character entropy yourself

This stand-in computes Shannon entropy per character position over a sample of tokens: a simplified version of Sequencer's character-level analysis. The sample generators are seeded so the output is deterministic.

Python Per-position entropy of token samples (stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

A uniform hex digit carries 4 bits. The weak sample shows positions with 0 bits (fixed prefix) and 1 or 2 bits (tiny choices), so its total is far under the 64 bits the length suggests. Sequencer reports exactly this kind of shortfall.

A counter is obvious

Some weaknesses are not about frequency counts but about order. A correlation test notices when each token is just the previous one plus something small.

Python Detect sequential tokens (stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

What to do with a poor result

Report it with the evidence: how many samples, the estimated bits, and which positions failed. The fix is to use the framework's built-in session manager or a CSPRNG (secrets.token_urlsafe(32) in Python, SecureRandom in Java, crypto.randomBytes in Node), regenerate the token at login, and never derive it from user data. Link the finding to the report writing steps later in this track.

A token passing Sequencer does not make the session secure. You still need HttpOnly, Secure and SameSite flags, HTTPS everywhere, an idle timeout, and server-side invalidation on logout. Randomness is one property among several.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Why must session tokens be unpredictable?

    The token alone proves identity to the server, so a guessable one equals a stolen account.
  2. 2. What does Burp Sequencer measure?

    Sequencer runs statistical tests on a sample of tokens to estimate their entropy.
  3. 3. A 32-character token has a fixed 24-character prefix. What is its effective entropy limited by?

    Fixed characters add no unpredictability, so only the varying part counts.
  4. 4. Which is a correct fix for weak tokens?

    A CSPRNG with enough length gives unpredictable values; rotating at login prevents fixation.
  5. 5. Roughly how many samples should you aim for before trusting Sequencer's conclusion?

    Statistical tests need large samples; Burp suggests around 10,000 for a final judgement.

Summary

  • A session token is the user's identity on the wire, so it must be long, random and opaque.
  • Sequencer captures many tokens and tests them with character, bit and FIPS-style analyses, reporting effective entropy.
  • Fixed prefixes, counters, timestamps and encoded user data are classic weaknesses.
  • Fix with a CSPRNG, rotate on login, and keep cookie flags and server-side invalidation.
  • The Sequencer output here is labelled example output; the Python blocks are stand-ins.

Next: Testing login and lockout defences