this post was submitted on 22 Mar 2025
761 points (100.0% liked)

Programmer Humor

22113 readers
555 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 8 points 1 week ago (3 children)

Avoiding 403 seems like a security through obscurity approach to me.

I suppose there might be some special admin only endpoints you'd want to 404 on if the user is not an admin. But for most cases it's really hell integrating an API that 404s on everything... is my token invalid, did I set a parameter wrong, or did I get the path wrong? I guess I gotta spend all day doing trial and error to figure it out. Fun!

Also makes integration tests on your security unreliable. Someone renames an endpoint and suddenly your integration tests aren't actually testing security anymore. Checking for 403 and getting a 404 because someone renamed something will indicate the test needs to be updated to use the new path. Checking for 404 (because the user isn't supposed to have access) and getting 404 (because the path was changed) means your test is useless but you won't know it was rendered useless.

[–] [email protected] 3 points 1 week ago* (last edited 1 week ago)

It depends on the context. If it's an URL that is easy to guess and reflects user-created content, your system is leaking information about their users if it returns 403. The example that comes to mind is GitHub returning 404s for both nonexisting and private repos when the authenticated user doesn't have access to it.

[–] [email protected] 2 points 1 week ago

Some osint tools use this : they test an email on thousands of services, and use the error result (403/404) to know if the person has an account there.

[–] [email protected] 1 points 1 week ago* (last edited 1 week ago)

No.

404 is for "I can not confirm this resource exists"

For example, a private github repo must return 404 for unauthorized users, API requests must act as if that repository doesn't exist (including returning 404 status codes).

403 is for "I can confirm this resource exists, you cannot access it"