Note: This write-up reflects my learning and hands-on practice based on the book The Web Application Hacker's Handbook: Discovering and Exploiting Security Flaws by Dafydd Stuttard and Marcus Pinto.

Attacking Application Logic:

What is "logic" in a web application?

Every web application (like a banking site, shopping website, or college portal) works based on logic. Logic means rules and decisions that tell the application what to do in different situations.

Web applications rely heavily on logic, which converts human requirements into small executable steps. Logic flaws are hard to detect, often missed by automated tools, and overlooked compared to common vulnerabilities like SQL injection. Due to their uniqueness and subtlety, logic flaws are highly valuable targets for attackers.

The Nature of Logic Flaws:

Logic flaws are errors in application reasoning caused by faulty or incomplete assumptions made by developers. They have no fixed patterns, making them difficult for automated tools and standard testing to detect. Due to their diversity and subtlety, logic flaws remain a long-term and valuable target for attackers.

Real-World Logic Flaws:

Example1: Fooling a Password Change Function

Step1: (Goal: Normal password change)

None

Step2: (Goal: The logic flaw attack)

None

This exploits the logic flaw. No existingPassword parameter at all.

Step3: (Goal: Verify if the attack worked)

None

In case it is secured then the following output would have came:

None

Example2: Proceeding to Checkout

Step1: (Goal: Check the normal behaviour)

Add item to cart:

None

Review cart:

None

Payment (legitimate):

None

Delivery (legitimate):

None

Step2: (Goal: Forced browsing)

Add item to cart (same as normal):

None

Jump straight to delivery:

None

Clearly, Order placed WITHOUT payment.

Verify the Exploit:

None

Example3: Rolling Your Own Insurance

Step1: Open the Burp Suite, and in the browser open the website as shown below:

None

Step2: Enter the amount in normal way, and proceed normally:

None

Then,

None

Then,

None

Then,

None

Observe the burp:

None

See the /step1. And the /step2:

None

Step3: (Goal: Change Price After Step 1)

For this, forward the request to repeater:

None

Example4: Breaking the Bank

Browser:

None

Step1: (Goal: Login as normal user). Alice:alice123

None

Now, click on "Register Another Account" and register the other account:

None

Following confirmation comes:

None

The app did: session["customer"] = create_customer_object(data, cust_number)

It OVERWROTE our authenticated identity.

Step2: (Goal: Over writing the registration)

In the new tab, go to the '/dashboard' :

None

We logged in as Alice… But now we're inside Bob's account.

Why This Is Dangerous? The app reused the same object: session["customer"]

For:

· Authentication

· Registration

· Identity storage

Registration overwrote it.

Example5: Erasing an Audit Trail

Browser:

None

Step1: (Goal: Login as the normal user)

None

Following dashboard shall appear:

None

Step2: (Goal: To exploit) Create a fake admin. Go to the "create user" link:

None

Fill it like this, and click on "Create" button, and then logout:

None

Now, login as the tempadmin:

None

Step3: (Goal: Malicious activity)

Click on : Reset all passwords. Now every user password = hacked

None

Click on: Delete Audit Logs.

None

Now, Click on View logs:

None

Everything else is gone.

What Happened?

The system assumed: If someone deletes logs, the deletion itself will be logged.

But:

1. You created a second admin.

2. Used it for attack.

3. Deleted logs.

4. Only entry left points to fake account.

There is no evidence linking original admin. Perfect crime.

Example6: Beating a Business Limit

Browser:

None

When clicked on "Login":

None

Again,

None

Step1: (Goal: Normal test)

None

When clicked on "Transfer" button:

None

Clearly, Protection works for positive numbers.

Step2: (Goal: bypassing)

None

When did:

None

Transfer 20,000 from A → B. WITHOUT approval.

Balances become:

Account A: 30000

Account B: 30000

We bypassed anti-fraud protection.

Example7: Cheating on Bulk Discounts

Browser:

None

Step1: (Goal: Normal behaviour)

None

Add the first three, then visit the View Cart:

None

Clearly, Discount applied.

Step2: (Goal: To cheat)

Remove any two of them from the cart:

None

Original price was $80. We still have 25% discount. System did NOT recalculate.

Example8: Abusing a Search Function

Browser:

None

Step1: (Goal: Broad Search) Search: Wahh Consulting

None

We are NOT subscribed. We see titles but no content.

Step2: (Goal: Try Narrowing) Search: Wahh Consulting takeover

None

We just learned: One article contains the word "takeover".

Step3: (Goal: Refine further) Search: Wahh Consulting takeover NGS

None

Step4: (Goal: Test Different Outcomes)

Search: Wahh Consulting takeover cancelled -> 0 matches

Search: Wahh Consulting takeover completed -> 0 matches

Without subscribing, we just reconstructed: Wahh Consulting completed takeover of NGS, is not present.

Example9: Snarfing Debug Messages

Browser1:

None

Browser2:

None

Step1: (Goal: Login)

· Browser 1 → Login as alice

· Browser 2 → Login as bob

Browser 1:

None

Browser 2:

None

Step2: (Goal: Alice Triggers an Error)

In Browser 1 (Alice):

Go to: Transfer Money

None

Try to transfer the money 񠛸'.

None

This triggers the artificial bug.

We get redirected to: /error

You'll see:

· Alice's username

· Alice's session token

· Alice's parameters

· Error message

So far, this seems normal.

Step3: (Goal: Bob Steals Alice's Debug Info)

In Browser 2 (Bob): Without triggering any error, manually go to:

http://127.0.0.1:5000/error

None

Bob now sees:

· Alice's username

· Alice's session token

· Alice's transfer details

This is cross-user data leakage.

Example10: Racing against the Login

Browser:

None

Race condition:

None

Avoiding Logic Flaws:

Logic flaws are prevented by:

· Clear documentation

· Strict session-based identity

· No shared mutable state

· Careful state transitions

· Defensive design reviews

· Lateral thinking during code review

Contact Me 📧 Email: adii.utsav@gmail.com 🔗 LinkedIn: https://www.linkedin.com/in/aditya-kumar-3241b6286/ 💻 GitHub: https://github.com/Rememberful