r/FullStackDevelopers • • 6d ago

How can I make my Vibe coded website secure

I've been learning about building full-stack e-commerce websites with Backend database admin panel.. through out the process I've been adding new tools like Fast2SMS/Resend(for sms services), Aws ses(for Authentication, forget password type emails), Stitch(for web design), Ai studio(for code) and Supabase for Backend and database.

I never give Ai my api keys all those keys(aws ses, Fast2SMS) i added using supabase and i secure supabase with Row Level Security.. other than that I put 30 second timer on OTP send button

This is enough? Or I need to secure anything else?

2 Upvotes

15 comments sorted by

1

u/Secvura 5d ago

If the 30 second timer is only on the button, it only exists in the browser, so anyone can call whatever sends the OTP directly and skip it. Put a limit on the server side too (per phone number and per IP, plus a daily cap), otherwise someone can spam it and run up your Fast2SMS bill.

RLS being on is only half of it, the policies are what matter. Check that users can't update columns like role or is_admin on their own profile row, that the admin panel is protected by policies and not just hidden in the UI, and that order totals are worked out server side rather than trusted from the cart. And keep the service_role key and the SES/Fast2SMS keys server side only (Edge Function secrets, for example), never in frontend code or in a table that logged-in or anonymous users can read.

1

u/mxrkkkkkkkkkk 5d ago

I put rate limiting through Supabase so even if hacker bypass storefront supabase still won't send another otp until 30seconds are over.. also I make a rls that No customer can read other customers data, no one can change his role from customer to admin

Actually I didn't hide admin panel in UI.. i created two seperate websites, one is storefront(who read data from supabase and send orders to supabase) and second is admin panel(who can change, upload, Delete or create sku and accept order and admin panel also take supabase as single source of truth

1

u/greedy-brady 5d ago

Having two separate sites is good for organisation, but it isn't the security boundary. Both talk to the same project URL with the same anon key, and the storefront sends that key to every visitor's browser. So anyone can skip your admin site and call the Supabase API directly. The only thing that stops them is the RLS policies on the SKU and order tables.

A quick way to check: sign in to the storefront as a normal customer, then use supabase-js with that URL and anon key to try inserting, updating and deleting a product, and changing another customer's order status. All of it should fail. Try it again while signed out.

Also check where your admin flag comes from. If the policies read a role from a profiles table, make sure a customer can't create their own profile row with role set to admin at signup, not only that they can't update it later.

1

u/mxrkkkkkkkkkk 5d ago

Yah i secure everything with RLS no customer can change, delete, edit anything... Customers can only view products, select side, apply coupon code(if any) and place order) also no one can change their role to admin or customer

Storefronts This is my demo website

1

u/greedy-brady 5d ago

Sounds like you've covered the main ones. One more spot worth a look, since customers can place orders and apply coupons: if the storefront inserts the order row straight into the table, RLS checks who is inserting, not whether the total or discount is right. Someone could send an order with a lower price or a made-up coupon.

If the total and coupon are worked out inside a database function (or Edge Function) from the product and coupon tables, and customers can only create orders through that, that gap is closed.

1

u/mxrkkkkkkkkkk 5d ago

Only admin can create coupon and decide who can use it(minimum order value and how many users can) and customer can only use those coupons(rls stops them creating their own coupons).. But I will recheck this part ig you're right i missed some points you just mentioned.

Thanks✨️

2

u/greedy-brady 5d ago

Glad it helped, good luck with the launch!

1

u/mxrkkkkkkkkkk 5d ago

Thnkx✨️😄

1

u/mxrkkkkkkkkkk 5d ago

Btw I didn't use service role key.. i just use Anon key and supabase url

1

u/Secvura 5d ago

Good to hear on the service role key. The anon key is the right one for both sites as long as the RLS policies hold, and it sounds like they do.

One thing on the OTP limit: if the 30 seconds is per phone number, it stops someone spamming one number but not someone cycling through lots of different numbers, since each new number gets its own fresh 30 seconds and the bill can still climb. A cap on the total number of OTPs sent per hour or per day, across all numbers, is what actually puts a ceiling on the cost.

1

u/Simple-Sea7054 4d ago

Great start keeping your API keys out of prompts and enabling RLS! Since it's an e-commerce app, add these four essentials before going live:

Backend rate limiting: A frontend 30-second timer is easy to bypass. Add server-side rate limiting (like Upstash or Cloudflare) to your OTP/SMS endpoints so bots can't drain your Fast2SMS/AWS credits.

Strict RLS & Admin checks: Make sure your RLS policies restrict users to only their own data ( auth. uid() = user_id ), and verify admin roles on the backend-don't just hide the admin UI.

Server-side pricing: Never trust cart totals sent from the frontend. Always fetch real prices from Supabase on your backend before processing payments.

Billing alerts: Set hard spending caps on AWS SES and Fast2SMS immediately to prevent surprise bills from spam attacks.

1

u/Electronic-Sun-9342 1d ago

CF can help with rate limiting, but id make sure the limits are enforced server-side regardless of which service u use. For an e-commerce app, server-side pricing validation, payment verification, and proper admin authorization are just as important as protecting OTP endpoints.

1

u/Simple-Sea7054 1d ago

100% agree. Cloudflare works great at

the edge, but pairing it with strict backend rate limiting (like Upstash/Redis) ensures nothing slips through if someone hits the origin directly. Also great callout on payment verification-verifying webhooks/signatures server-side before fulfilling orders is definitely just as critical as locking down the cart prices.