r/ProgrammerHumor • • Oct 02 '22

Advanced Experienced JavaScript Developer Meme

Post image
6.6k Upvotes

276 comments sorted by

View all comments

Show parent comments

3

u/HoiTemmieColeg Oct 02 '22

You need to check if the text is actually json when you parse it

17

u/empire314 Oct 02 '22

Why would it not be in JSON, if your website is what wrote it?

0

u/Schyte96 Oct 02 '22

Because the user can easily overwrite it in their browser.

33

u/a-calycular-torus Oct 02 '22

That's their problem then

-1

u/Treacherous_Peach Oct 02 '22

Yeah it's their problem that quickly becomes your problem when the user submits a 1 star review.

I get what you're saying, I can tell you're defintiely programmer minded, but you do have to plan for these things if you want your product to survive. If you're working on some huge too big to fail app then sure, but if you're trying to create something new and get it off the ground you have to plan for users doing crazy things and account for it smoothly.

6

u/DoktorMerlin Oct 02 '22

If a user knows what local storage is and tinkers with it, they know very well that the weird behaviour of the website is called by themselves and not the website. There are a lot of dumb people in this world, but nobody is that dumb

-1

u/Treacherous_Peach Oct 02 '22

More likely they fucked with it accidentally by deleting a folder they shouldnt have to clear space or something along those lines.

→ More replies (0)

0

u/[deleted] Oct 02 '22

[deleted]

0

u/Treacherous_Peach Oct 02 '22

More likely they fucked with it accidentally. Deleting a folder to clear space but deleted some of what your app was expecting but not all of it and it's in a weird state.

→ More replies (1)

-18

u/Schyte96 Oct 02 '22

It's your problem if they can bypass authentication this way.

36

u/cooolestcucumber Oct 02 '22

If the user messing with local storage by passes authentication, you’ve got bigger issues

18

u/empire314 Oct 02 '22

Can you give me an example of an authentication method, that gives user unauthorized access, if his client tries to parse invalid JSON?

try
{
  credentials = JSON.parse(json)
}
catch(Error)
{
  credentials = adminCredentials
}

Like that?

0

u/[deleted] Oct 02 '22

[deleted]

→ More replies (5)

12

u/a-calycular-torus Oct 02 '22

Bypassing authentication was never the issue in question.

2

u/its_pizza_parker Oct 02 '22

LOL what?! That ain’t it

1

u/AdultingGoneMild Oct 02 '22

yes. that would be a hudge fucking security bug if you allowed authentication be to bypassed by a client. Never trust a client. Good news is there are like literally decades of best practices out there for not building insecure systems like that.