SecurityArticle

You Built the App. Now Make Sure the Backend Is Tight.

Getting an app to work and getting it ready for real users are two different things. What I've learned about backend security fundamentals: access control, PII, private files, keys, validation, and testing that the controls actually work.
August 24, 202611 min readPhysara

You built the app.

The front end looks good. The buttons work. Users can create accounts. Data is saving. Maybe you even have some AI features running in the background.

At that point, it's easy to feel like you're basically done.

You're not.

One of the biggest things I've learned while building my own products is that getting an app to work and getting an app ready for real users are two different things.

I had already been introduced to a lot of the fundamentals while studying for my degree. Databases, networking, authentication, access control, protecting information, all of that. But once I started building real products and working with actual user accounts, databases, APIs, and personal information, it started to hit differently.

Now it wasn't just something I understood for an assignment.

If somebody trusted a product I built with their information, I had to make sure I was handling it properly.

That's where the backend matters.

And I don't mean every app needs some crazy military-grade security setup. A lot of backend security comes down to getting the fundamentals right.

Who can see what?

Who can change what?

Are private files actually private?

Are important keys protected?

Are you collecting personal information you don't actually need?

Can someone manipulate a request and access another user's data?

Can someone spam a feature that costs you money?

None of that is rocket science.

But ignoring it can create some very real problems.

Why Backend Security Matters

Imagine you build a platform where customers create accounts, save projects, upload documents, and manage information from a dashboard.

When you test it normally, everything works.

User A logs in and sees their projects.

User B logs in and sees theirs.

Perfect.

But what happens if somebody changes a project ID inside a request?

Maybe the app normally loads:

Text
/projects/123

Someone changes it to:

Text
/projects/124

If your backend isn't checking who actually owns project 124, that person might suddenly be looking at someone else's information.

Maybe that project contains:

  • A customer's name
  • Email address
  • Private notes
  • Uploaded documents
  • Company information
  • Order details

The person didn't need to pull off some insane hack.

The system simply let them access something it shouldn't have.

That's the kind of thing backend security is supposed to prevent.

Think About It Like a Gym

The easiest comparison for me is a gym.

You walk into the gym and scan your membership.

Now the gym knows you're a member.

That doesn't mean you can walk behind the front desk.

You can't open the manager's office.

You can't pull up everybody's billing records.

And your locker key definitely shouldn't open every locker in the building.

Software works the same way.

Logging into an app answers:

Who are you?

That's authentication.

But then the application still has to answer:

What are you allowed to do?

That's authorization.

Those are two different things.

Just because someone has a valid account doesn't mean they should have access to everybody else's information.

The Front End Can't Be the Only Thing Protecting You

Let's say your app only shows an Edit button when somebody owns the project.

Something like:

TypeScript
if (project.userId === currentUser.id) {
  showEditButton();
}

That's fine for the user interface.

But it isn't security by itself.

Someone doesn't have to click your buttons.

They can inspect network requests.

They can change an ID.

They can call an endpoint directly.

They can write a simple script.

So the backend should still check ownership.

TypeScript
if (project.userId !== authenticatedUser.id) {
  return new Response("Unauthorized", {
    status: 403,
  });
}

That's the difference.

You're not saying:

The button isn't there, so they can't do it.

You're saying:

Even if they try, the system won't allow it.

That's a much better place to be.

Database Policies Matter

If you're using something like Supabase, Row Level Security, or RLS, is one way to enforce these rules directly at the database level.

A basic example could look like this:

SQL
create policy "Users can read their own projects"
on projects
for select
using (auth.uid() = user_id);

In plain English:

Only let a user read the project if the project belongs to them.

Now even if somebody tries to request another user's project manually, the database should reject it.

And you shouldn't only think about reading data.

Think about all of it:

Text
READ
CREATE
UPDATE
DELETE

A user shouldn't be able to update another user's information.

They shouldn't be able to delete it either.

The backend should enforce that.

What Can Actually Happen If You Ignore This?

This is where the topic stops being theoretical.

Someone could see another user's information

Maybe your app stores:

  • Names
  • Email addresses
  • Phone numbers
  • Customer records
  • Messages
  • Documents
  • Order history
  • Account information

If your access rules are wrong, one user could potentially access another user's data.

Once that happens, you don't just have a technical problem.

You have a trust problem.

Someone Could Change or Delete Data

Security isn't only about somebody stealing information.

Imagine logging into a project management platform and realizing another person changed your project.

Or deleted a document.

Or modified an order.

Or changed information on your account.

The backend has to protect against unauthorized changes too.

That's why permissions for UPDATE and DELETE matter just as much as reading.

Private Files Might Not Actually Be Private

This is another easy mistake to make.

Let's say your app lets someone upload a contract.

The user uploads it through their private account, so you assume the document is private.

That doesn't automatically mean it is.

If your storage settings are wrong, someone with the file URL may be able to access it.

For example:

Text
/uploads/customer-contract.pdf

If that URL is publicly accessible, you have a problem.

A better structure might look more like:

Text
user-123/documents/contract.pdf
user-456/documents/invoice.pdf

Then your storage policies make sure User 123 can only access User 123's files.

Same idea as the lockers at the gym.

Everyone can have a locker.

Your key should open yours.

Not everybody else's.

Then There's PII

PII stands for Personally Identifiable Information.

That's basically information that can identify a person.

Common examples include:

  • Full name
  • Email address
  • Phone number
  • Home address
  • Date of birth
  • Account identifiers

And depending on what your app does, you may have other information that deserves extra protection.

Documents.

Private messages.

Payment-related information.

Employee records.

User-generated photos.

Business records.

The important thing is knowing what information your product actually collects.

Because once you collect it, you're responsible for how it's handled.

Follow the Data

One habit I've picked up is thinking about the full path that user information takes.

Something like:

Follow the data
User
↓
Application
↓
Backend
↓
Database
↓
External Service
↓
Response

Then I ask questions at each step.

Text
What data is being sent?

Does it actually need to be sent?

Who can access it?

Where is it stored?

Is any of it being logged?

Can another user reach it?

Can the user delete it?

That becomes even more important when you're using outside services.

Don't Send More Data Than You Need

Let's say you build an AI feature.

It might be tempting to take the entire user object and send it along with the request.

TypeScript
await analyzeDocument({
  user,
  profile,
  history,
  document,
  preferences,
});

Maybe it works.

But does the service actually need all of that?

Maybe it only needs:

TypeScript
await analyzeDocument({
  document,
  requestedAnalysis,
});

That's better.

Instead of asking:

What information can I send?

I think the better question is:

What's the minimum amount of information this feature actually needs?

If a service doesn't need somebody's email, don't send the email.

If it doesn't need their name, don't send their name.

If it doesn't need their entire account, don't send their entire account.

Simple.

Be Careful With Logs

Logs are great when you're trying to figure out why something broke.

But logs can also accidentally become another place where sensitive information gets stored.

This:

TypeScript
console.log("Incoming request:", requestBody);

might look harmless.

Until requestBody contains:

JSON
{
  "email": "someone@example.com",
  "phone": "555-555-1234",
  "documentUrl": "private-document.pdf"
}

Now that information may be sitting in your logs too.

You usually don't need all of that just to know a request happened.

Something more limited might be enough:

TypeScript
console.log("Document analysis request", {
  requestId,
  status: "received",
});

Log what helps you debug.

Don't dump everything just because you can.

Protect Important Keys

Another important one is API keys and backend secrets.

Some keys are meant to be used in a frontend application.

Others definitely aren't.

A privileged backend key should stay on the backend.

TypeScript
const serviceKey = process.env.SUPABASE_SERVICE_ROLE_KEY;

If a key gives somebody powerful access to your database or another service, putting it in frontend code is basically like leaving the gym's master key on the counter.

Environment variables help, but you still have to understand where that variable ends up.

Just because something starts in .env doesn't automatically mean it's protected.

Validate What the Backend Receives

Your frontend might only allow users to enter reasonable information.

That doesn't mean the backend should blindly trust it.

Maybe your interface normally sends:

JSON
{
  "projectName": "New Website"
}

Someone could manually send:

JSON
{
  "projectName": "",
  "user_id": "someone-elses-id",
  "admin": true
}

The backend should decide what's valid.

For example:

TypeScript
if (
  typeof body.projectName !== "string" ||
  body.projectName.trim().length === 0
) {
  return new Response("Invalid project name", {
    status: 400,
  });
}

And if you're creating something for the logged-in user, don't blindly trust a user_id they send you.

Instead of:

TypeScript
const userId = body.user_id;

use the authenticated identity:

TypeScript
const userId = authenticatedUser.id;

The backend already knows who's logged in.

There's no reason to let someone pick who they want to be.

Rate Limits Matter Too

Not every attack involves stealing data.

Sometimes someone just abuses your system.

Let's say you have an AI feature that costs you money each time it runs.

A normal user might use it a few times.

But someone could automate thousands of requests:

Bash
for i in {1..10000}; do
  curl https://your-app.com/api/analyze
done

If there are no limits, that could become your bill.

Rate limiting helps control that.

The same goes for:

  • Login attempts
  • Password reset requests
  • AI requests
  • File uploads
  • Search endpoints
  • Expensive database operations

If a normal person shouldn't realistically do something 10,000 times in a minute, your backend probably shouldn't allow it.

Security Is Really About Trust

This is probably the biggest reason all of this matters to me.

When somebody creates an account in your product, they're trusting you.

They don't know what RLS is.

They probably don't care what database you're using.

They don't care what framework you chose.

They shouldn't have to.

They just expect you to handle their information responsibly.

If they're uploading something private, it should stay private.

If they delete their account, there should be a plan for what happens to their information.

If another user tries to access their data, the system should stop them.

That's part of building a real product.

Good security helps maintain that trust.

Bad security can destroy it very quickly.

You Don't Have to Make This Rocket Science

This is also something I think gets lost when people talk about security.

The topic can get intimidating really fast.

You start hearing terms like authentication, authorization, RLS, tokens, encryption, policies, secrets, scopes, CORS, rate limiting, attack surfaces.

It starts sounding like you need a cybersecurity team before you're allowed to build a basic app.

You don't.

Start with the basics.

Ask:

Text
Does every user only have access to what belongs to them?

Are important actions checked on the backend?

Are my private keys actually private?

Do I know what personal information I'm collecting?

Are private files protected?

Am I sending unnecessary data to other services?

Can somebody abuse my expensive endpoints?

Am I logging things I shouldn't be logging?

That's already a much better security mindset than just getting the app working and shipping it.

Test It

Probably the biggest lesson for me is not to assume something is protected because it looks protected.

Test it.

Create two accounts.

Try accessing one account's information from the other.

Change IDs.

Try calling the backend without using the interface.

Try uploading the wrong file type.

Try hitting an endpoint repeatedly.

Try deleting something you shouldn't have permission to delete.

You're basically asking:

What happens if somebody doesn't use my app the way I intended?

Because that's exactly what you need the backend to handle.

The App Working Isn't the Finish Line

Building software is easier and faster than it has ever been.

That's a good thing.

You can take an idea and turn it into something functional incredibly quickly now.

But the speed can make it feel finished before it actually is.

Before you start putting real users into your app, spend some time on the backend.

Check your policies.

Check your permissions.

Understand your PII.

Protect your files.

Protect your keys.

Validate requests.

Limit abuse.

Think about what you're sending to outside services.

And most importantly, test whether the controls actually work.

Getting the app to work is one accomplishment.

Making sure people can trust it is another.