← All posts

Field notes / Security

Think Like the Application Before You Think Like the Attacker

One of the easiest habits to develop in penetration testing is immediately asking:

How can I break this?

Give me an endpoint and my brain starts generating questions.

Can I access it without authentication?

Can I change an ID?

Can I inject something?

Can I bypass authorization?

Can I manipulate the request?

Those are useful questions. They are also sometimes the wrong questions to ask first.

Before asking how an application can fail, we need to understand what the application is actually trying to do.

That sounds obvious.

It isn't.

Start With the Happy Path

Consider a simple API endpoint:

POST /api/notes

The documentation says:

Creates a new note for the authenticated user.

The request body looks like this:

{
  "title": "Sprint Planning",
  "body": "Remember to rotate AWS keys."
}

Assume that's everything we know.

No source code.

No architecture diagram.

No Burp traffic.

No database schema.

An offensive-security instinct might immediately start testing the endpoint.

A security engineering approach starts somewhere else:

Tell the story of the request.

What is this endpoint supposed to accomplish?

What probably happens after the user clicks Save?

What decisions must the application make before that note becomes stored data?

And importantly:

What am I assuming because I don't actually know?

Make the Implicit Explicit

The documentation already gives us one important piece of information:

"for the authenticated user"

That suggests authentication exists somewhere in the request lifecycle.

But we don't know how.

It could be a session cookie.

It could be a bearer token.

It could involve an API gateway.

There may be additional infrastructure we can't see.

So rather than silently inventing an architecture, we can state the assumption:

I assume the user has already authenticated and the request contains some mechanism that allows the application to associate the request with that user.

That sentence matters.

Senior-level reasoning isn't just about reaching the right conclusion. It's about exposing the reasoning that produced it.

If something is part of your mental model, say it.

Otherwise nobody reviewing your work, interviewing you, or collaborating with you knows that you considered it.

Follow the Request

With our assumptions identified, we can construct a probable request lifecycle.

The browser or client sends something resembling:

POST /api/notes
Content-Type: application/json
Cookie: SESSION=abc123

with:

{
  "title": "Sprint Planning",
  "body": "Remember to rotate AWS keys."
}

The request reaches the application.

Now decisions begin.

Authentication

First:

Who is making this request?

The application needs to associate the request with an identity.

Maybe it validates a session.

Maybe it validates a token.

The exact implementation isn't known, and that's fine.

What matters is recognizing that some authentication decision probably needs to occur because the endpoint specifically creates a note for an authenticated user.

Authorization

Authentication answers:

Who are you?

Authorization answers:

Are you allowed to do this?

Those are different questions.

An authenticated account might exist without having permission to create notes.

Perhaps every user can create notes.

Perhaps only users with a certain subscription can.

Perhaps the account has been disabled or placed into a read-only state.

We don't know.

So we state another assumption:

I assume authenticated users are normally authorized to create notes unless another role, account state, or permission prevents it.

Now our reasoning is visible.

Business Rules

Authorization still isn't enough.

The application also needs to determine whether the requested operation makes sense according to its own rules.

For a note-taking application, possible rules might include:

These aren't necessarily traditional "security controls."

They're application rules.

And attackers routinely abuse assumptions encoded in business logic.

A coupon that should only work once but works 500 times is a security problem.

An invoice that accepts a negative amount may be a security problem.

A scheduling application that allows appointments in the past may expose a business-logic flaw.

Understanding business rules means asking:

Does this operation satisfy the rules that make this application behave correctly?

Validation

The application also needs to determine whether the supplied data is acceptable.

Does title exist?

Is it a string?

Is body allowed to be empty?

Are there maximum lengths?

Are unexpected fields accepted?

Again, we aren't hunting vulnerabilities yet.

We're identifying the decisions the application must make to successfully process a legitimate request.

Persistence

Eventually the application decides that the note should exist beyond the lifetime of this HTTP request.

That means it needs to be persisted.

Persistence doesn't mean keeping the user's session alive.

It means storing information so that it still exists later.

A note contains structured information:

user_id
title
body
created_at
updated_at

That kind of structured data would typically belong in a database.

If the application allowed an attachment, the architecture might look different.

The database could contain:

note_id
user_id
filename
object_key
content_type
created_at

while the actual PDF, image, ZIP archive, or other binary artifact lives in object storage.

A useful mental model is:

The database knows about the file. Object storage has the file.

That distinction becomes important when reasoning about architecture.

Applications enforce access.

Storage stores data.

The application should decide:

Is this user allowed to retrieve this object?

The storage system should not magically be expected to understand the application's business relationships.

Auditing

Successful persistence may also generate security-relevant records.

For example:

user 1842
created note 9371
2026-08-08T14:32:18Z

We don't know whether the application logs this action.

But we can identify auditing as another likely stage and explicitly say that its implementation is unknown.

This gives us a probable lifecycle:

Client
   ↓
Application
   ↓
Authentication
   ↓
Session Validation
   ↓
Authorization
   ↓
Business Rules
   ↓
Input Validation
   ↓
Persistence
   ↓
Auditing
   ↓
Response

The application might then return something like:

HTTP/1.1 201 Created

with the newly created resource.

The important part isn't memorizing this exact sequence.

Real systems vary.

The important part is learning to tell a coherent story about how an application transforms a request into a result.

Where OSI Ends and AppSec Begins

This also clarifies something that can initially feel strange if you're accustomed to networking models.

The OSI model and an application request lifecycle describe different things.

OSI asks:

How does information get from Point A to Point B?

Application security asks:

Once the information arrives, how does the application decide what to do with it?

The OSI model reaches Layer 7:

Physical
Data Link
Network
Transport
Session
Presentation
Application

For AppSec, reaching the application is where things get interesting.

We effectively zoom into Layer 7:

Application
    ↓
Authentication
    ↓
Session Validation
    ↓
Authorization
    ↓
Business Rules
    ↓
Persistence
    ↓
Auditing

Modern web session management isn't literally an implementation of the textbook OSI Session Layer.

But the conceptual problem of maintaining state across interactions still exists.

A cookie such as:

Cookie: SESSION=abc123

or a header such as:

Authorization: Bearer <token>

allows an application to associate otherwise independent HTTP requests with an identity or state.

Different model. Related concept.

Put Security Questions Where They Belong

Another useful change in thinking is resisting the temptation to ask every security question simultaneously.

Instead, attach each question to the part of the lifecycle responsible for answering it.

Authentication
    ↓
Is this user authenticated?

Authorization
    ↓
Can this user create notes?

Business Rules
    ↓
Is this operation allowed in the application's current state?

Validation
    ↓
Is the supplied data acceptable?

Persistence
    ↓
Where should this information be stored?

Auditing
    ↓
What should be recorded about this action?

This keeps an assessment from turning into an unordered pile of security questions.

It also makes gaps easier to identify.

If you can't explain where a particular decision happens, you've discovered something worth understanding.

Then Think Like the Attacker

Only after understanding the happy path should we deliberately move toward the unhappy path.

Now the offensive questions become much sharper.

Instead of vaguely asking:

Can I break this endpoint?

We can systematically challenge the assumptions we just identified.

What happens if authentication is missing?

What happens if the session belongs to another user?

What happens if authorization isn't enforced?

What happens if a business rule can be bypassed?

What happens if validation differs between components?

What happens if ownership isn't associated correctly during persistence?

What happens if stored data can later be retrieved by another tenant?

What happens if security-relevant actions aren't audited?

The attack surface hasn't disappeared.

We've organized it.

And that's the key difference.

A Repeatable Endpoint Review Method

For any endpoint, walk through the same sequence:

  1. What is this endpoint trying to accomplish?
  2. What assumptions am I making?
  3. What security decisions must occur?
  4. Where is the data stored?
  5. What trust boundaries are crossed?
  6. What could go wrong?

Notice where exploitation appears.

Last.

Not because vulnerabilities are unimportant.

Because vulnerability analysis becomes much more effective once you understand what the system was supposed to do.

That's the shift from simply attacking applications to reasoning about them.

Understand the application first. Then attack your understanding of it.

← Back to the blog