DEV Community

Mike Whitaker
Mike Whitaker

Posted on

2 1

Design your own security vulnerability #1

The first in probably an even more occasional series... None of these are new. But people keep making the same tired old mistakes.

We begin, as ever, with the best of intentions. As part of our business, let's store some customer data by customer ID, where customer ID is a numeric key on our database of customers. Most databases will happily generate this for you and increment it by one when you add a new customer.

Let's have a web page so the customer can see his own data, say at https://my-safe-data.biz/customer/NNNNN where NNNNN is the customer ID. Fine and dandy. No-one but the customer and us know his ID, so he's quite safe. We can just pass that ID to the database, ask it for the data for that customer, and present it. Don't need to password protect it, because the ID is its own password, right - no-one knows anyone else's customer ID, do they, surely??

Wrong.

You don't have to know anyone else's customer ID. Just make an educated guess on how they're generated.

Enter J Random Cracker, who just happens to have seen one of our URLs because he's a customer. "I wonder", they think, "what happens if I change my customer ID by 1"...

"Oh look. Someone else's records." An hour and a bit of scripting later, and they've pulled out LOTS of records to which they have no right.

"But", you say, "no-one would be that stupid, would they?"

Well yes. They would (and yes, just one of many examples, before you ask).

One easy fix is to require a login before you can access your own data, but that opens more potential vulnerabilities. Of which more later.

Another is to use a different method of generating customer IDs.

Same applies.

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay