Replying to Avatar sperry

My sons first website, that he built yesterday...

https://phenomenal-kringle-f50435.netlify.app/

Proud he incorporated bitcoin, but that's what you need to do when you don't have access to payment processors.

drysky515@getalby.com if you care to send him a few sats.

Where can I report a major security issue ?

Reply to this note

Please Login to reply.

Discussion

To me please!!!!

The site has moved, but what's the issue?

https://case-files.netlify.app/

- Anyone can edit localStorage to set `IsAdmin=1` and gain admin privileges.

- The password is fetched from the database and stored in a local variable, so it can be easily accessed through the browser console.

I redeployed, could you check now, please? Thanks so much! Very valuable feedback.

You're welcome, it's like a Capture The Flag (; !

It’s a good thing you no longer have a big "Admin Login" button at the top.

That said, you can still just type "state.adminPassword" in the browser console to get the password.

The issue is that the login process seems to be entirely handled by the client.

To put it simply, a website’s code is usually split into two parts:

- Client-side: This is the JavaScript and HTML that runs directly on the visitor’s computer. The visitor can easily view and modify this code from their browser. You should never trust the client, nor use it to store sensitive information, because everything is publicly accessible and editable. LocalStorage and cookies are also stored client-side.

- Server-side: The code can be in various languages like PHP and runs on the server. If your server is secure, the code and data stored there won’t be publicly accessible. This is where the database should be, and it’s also where password verification should happen, so the password never has to be sent to the client.

These two parts communicate via HTTP requests (POST, GET, etc.). The server should never trust what the client sends, because it can be manipulated.

For a login system with VERY BASIC security:

- The user enters their password.

- The password is sent to the server via an HTTP POST request, either using the `fetch` function or an HTML form.

- The server receives the password and compares it to the real one.

- If the password is valid, the server creates an encrypted session variable with a secure token.

This way, the client never receives the password.

Yes, this is a lot to set up for an admin login, not to mention other things like brute-force protection or encryption. But there’s a simpler way to handle authentication without managing it yourself: you can use OAuth, which delegates authentication to a third party like Google or even Nostr.

Unfortunately, there’s another issue. Your site uses Firebase to store data, but the Firebase API key, which grants full access to the database, is stored client-side and is therefore public. So anybody can update and read your Firebase database. I’m not an expert on Firebase, but secrets and databases should always be managed server-side.

It seems like you haven’t written any server-side code, and I don’t think Netlify allows it. So either you make a purely client-side (static) page like you’re doing now, embed the book data directly in the JavaScript, and remove the admin page entirely. Or, the more flexible but also more complex solution: use a server that supports something like PHP, set up your own database or use Firebase properly, and implement either secure authentication or OAuth.

That’s it. I hope this was clear and not too discouraging. I’m not a specialist either, so I might have missed some other options.

Good luck, and if you need help, don’t hesitate to reach out, it’s my pleasure.

(I used automatic translation from french to english, because it's easier for me)

- Passwords must never be sent to the client, all login verification must be handled exclusively on the backend.

- IsAdmin must be stored in a server-controlled, encrypted session variable.

- A great security practice is to hash passwords before storing them in the database.

congratulations to your son on his first website !

Thanks for taking the time out to check and provide this feedback. We are grateful in this house to know about NOSTR and have such a helpful community.

I'll pass on the congratulations.

Cheers!

Is it the admin password hard coded in the js? Fixing that now.