惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MongoDB | Blog
MongoDB | Blog
B
Blog RSS Feed
MyScale Blog
MyScale Blog
M
MIT News - Artificial intelligence
H
Hackread – Cybersecurity News, Data Breaches, AI and More
J
Java Code Geeks
U
Unit 42
Blog — PlanetScale
Blog — PlanetScale
L
LangChain Blog
C
Check Point Blog
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
人人都是产品经理
人人都是产品经理
T
Tailwind CSS Blog
Vercel News
Vercel News
腾讯CDC
GbyAI
GbyAI
有赞技术团队
有赞技术团队
S
SegmentFault 最新的问题
H
Help Net Security
博客园 - 三生石上(FineUI控件)
D
DataBreaches.Net
Microsoft Security Blog
Microsoft Security Blog
小众软件
小众软件

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
The Pentester’s Guide to Finding CBC Bit Flipping Vulnera...
Arashad Dodhiya · 2026-06-17 · via DEV Community

If you spend enough time poking at web applications, you’ll eventually run into a target that handles session management poorly. You’ll intercept a request, look at the cookie, and see a massive, encrypted string.

For a lot of testers, encrypted state data is a dead end. If you can’t read it, you move on.

But if that application is relying on CBC (Cipher Block Chaining) mode without implementing an integrity check (like a MAC), that encrypted cookie isn't a dead end. It’s an attack vector.

Here is a practical, step-by-step methodology for testing web applications for CBC bit flipping vulnerabilities safely and effectively.

The Methodology: How to Test for Bit Flipping

Testing for this flaw requires a mix of cryptography knowledge and standard web manipulation. You aren't trying to crack the encryption key; you are intentionally corrupting the ciphertext in transit to see how the backend application reacts to the resulting corrupted plaintext.

1. Capture the Encrypted Cookie

First, you need to isolate the target data. Route your traffic through an intercepting proxy like Burp Suite or OWASP ZAP. Look for session identifiers, auth tokens, or state parameters that look like encrypted blobs.

Hint: If the application uses a recognizable format like JWT, this attack likely doesn't apply (JWTs have built-in signature verification). You are looking for opaque, proprietary encrypted strings.

2. Decode the Transport Format

Ciphertext is raw binary, which doesn't travel well over HTTP. Developers almost always encode it. Before you can manipulate the blocks, you need to strip away the transport encoding.

  • Is it Base64 encoded? (Look for == padding at the end).
  • Is it Hex encoded? (Look for strings of 0-9 and A-F).
  • Is it URL encoded? (Look for % symbols).

Decode the string down to its raw bytes. If you try to flip bits on a Base64 string directly, you'll break the encoding itself, not the underlying ciphertext.

3. Identify the Block Boundaries

AES operates on strict 16-byte (128-bit) blocks. Once you have the raw ciphertext, conceptually divide it into 16-byte chunks.

If the cookie is exactly 32 bytes, you have two blocks. If it's 48 bytes, you have three.
The core mechanic of CBC bit flipping is that modifying a byte in Block N will alter the corresponding decrypted byte in Block N+1.

If you suspect the sensitive data (like role=user) is in the second block, you need to target your modifications at the first block.

4. Modify the Ciphertext (The Flip)

This is where the magic happens.

To systematically test the application, you alter a single byte in the ciphertext block preceding your target block.

If you know the exact plaintext structure (e.g., you know the cookie format is exactly userid=123;role=user), you can use XOR math to calculate exactly which byte to flip to change user to admi.

If you don't know the plaintext structure—which is common in black-box testing—you have to fuzz it. Systematically alter bytes one by one in the target block.

5. Replay the Request

Re-encode your modified ciphertext (e.g., back into Base64, then URL encoding) and inject it back into the cookie header. Forward the modified request to the server.

6. Observe Application Behavior

The server is going to decrypt your modified cookie. Because you altered the previous block, the decrypted plaintext for the current block will be scrambled.

You need to observe how the application reacts:

  • Authorization Change: Did you suddenly gain access to an admin panel or another user's account? (Bingo. Successful exploit).
  • Application Errors (500 Internal Server Error): The application decrypted the data, but the resulting plaintext was garbage (e.g., role=x$9p), causing a database lookup to fail or a parsing error. This is a strong indicator that the application is vulnerable to tampering, even if your specific payload didn't grant access.
  • Silent Failure/Logout: The application might redirect you to the login screen. It either successfully parsed your broken string and couldn't find a matching session, or it did have an integrity check (like a MAC) that caught your tampering and killed the session.

Common False Positives

When hunting for this, it is easy to misinterpret the server's response. Watch out for these traps:

  • Padding Oracles: If you modify the very last block, or modify bytes that result in invalid PKCS#7 padding, the server might throw a specific cryptographic error. This is a Padding Oracle vulnerability—which is great—but it is a different attack than pure bit flipping.
  • WAF Interventions: If you flip a byte and the resulting decrypted plaintext happens to contain characters like ' or <script>, a Web Application Firewall might block the request. You might see a 403 Forbidden and assume the crypto caught you, but it was actually the WAF catching the garbage output.
  • Format Exceptions: Just because the server throws a 500 error doesn't mean you can successfully exploit it for privilege escalation. Sometimes, the data structure is so rigid that any flipped bit breaks the application logic before it can be exploited.

The Golden Rule: Safe Testing Methodology

When testing production systems for bug bounties or client pentests, tread lightly.
Bit flipping corrupts data. If the application writes that decrypted, corrupted state back into a database, you could permanently break your test account (or worse, impact other systems).

Always conduct these tests using accounts you own and control. Start by flipping a single, low-impact bit and monitoring the exact HTTP response. Don't run an automated script that fires 10,000 modified cookies at a production endpoint without understanding how the backend handles the garbage data you are generating.

Finding a CBC bit-flipping flaw is incredibly satisfying. It proves that you went beyond the surface-level web vulnerabilities and broke the underlying logic of the application's trust model.