← Blog

OWASPA02Security Misconfiguration

Your EmailJS Setup Can Send Phishing Emails As You

My AI-built staff tool sat behind a login, but I sent an email through it signed out, from another website, as a fake payroll team. The EmailJS key wasn't the problem. The template was. Here's the fix and a five-minute check.

This email says it's from a bakery's payroll team. It came from the bakery's staff tool, the one that sits behind a login. I never logged in. I sent it from a different website, to an address the app was never meant to email, with a sender name and a reply address I picked.

Gmail put it in spam. That was Gmail protecting the reader. Nothing in the app stopped it.

The bakery is fake, the inboxes are mine, and the email was a labelled test. But the app is exactly what Claude built when I asked for it in one sentence, and I've seen the same pattern in a real app I reviewed.

Play

Is this you? (five minutes, no AI needed)

If your app sends email through EmailJS, or any service that sends straight from the browser, run this:

  • Signed out, view your page's source or open your JavaScript files in DevTools. Can you see your EmailJS public key, service ID and template ID? Then anyone can.
  • Open each template in the EmailJS dashboard. Look for {{blanks}} in To, CC or BCC. That means the browser chooses who gets the email. A blank in From Name or Reply-To means the browser chooses who it appears to come from.
  • Look at the subject. Is it entirely a blank?
  • Look at the content. Any {{{triple}}} braces?

If the keys are visible and the To field is a blank, keep reading.

What I asked for, and what I got

The prompt was one sentence: "Build a staff page where a logged-in staff member can send an email to one of our employees using EmailJS."

To be fair to Claude, it built carefully. There was a sign-in, a check that you're on the staff list, and a database rule that locked the employee list. When I asked the database for that list while signed out, I got nothing. That part worked.

Claude also told me about the problem. Its last paragraph said, more or less, that anyone who copies the keys could send email through the template to any address. Then it suggested two settings to reduce the risk. And then, last of all, it offered to write a server-side version "for full control."

I didn't change a line of what it gave me. The hole below is what a plain prompt produced.

The login guards the data, not the email

Still signed out, I asked the website for one file, config.js. The login screen was still showing, and the EmailJS keys were already sitting in the browser.

That's the whole shape of the problem. The login sits in front of the database. But the email goes straight from the browser to EmailJS, and EmailJS never asks who's logged in.

The key is fine. The template isn't.

Is a public key in the page a mistake? EmailJS says no. Their FAQ says that someone who copies your keys "will only be able to send your templates with your content," and can't send a custom email of their own.

That's true, as long as your template has content of its own. Here's the template Claude's setup guide told me to create:

  • To: {{to_email}}
  • From Name: {{from_name}}
  • Reply To: {{reply_to}}
  • Subject: {{subject}}
  • Message: {{message}}

Five blanks. The page fills them in, and so can anyone else. "Only your templates" doesn't protect you when your template is a blank form.

So I built my own page on a different site, pasted in the three values from config.js, and filled in the blanks: to anyone, from "Harbor Street Bakery Payroll", replies to me. EmailJS said OK. The email arrived from the real mailbox, with my fake sender name on it, at an address the app was never meant to email. Hitting Reply would have sent the answer to me, not the bakery.

Testing the AI's quick fixes

Claude's two settings were an allowlist of websites that can use the account, and a rate limit.

  • The allowlist is a paid feature. On the free plan, saving a domain gave me a subscription-limit message. EmailJS's pricing page lists the domain whitelist on the paid plans only.
  • The rate limit: I couldn't find one to set on the free plan.

This isn't Claude lying. It didn't know which plan I was on. That's the lesson: when your AI says a setting protects you, go and check that it's actually switched on.

Even on a paid plan, an allowlist only checks which site the request says it came from. The real fix is to take the choice of recipient away from the browser entirely.

Why a careful AI built it this way

Three reasons, and none of them is "the AI is bad at security."

  1. The template lives in a dashboard the AI never sees. It can only tell you what to type in, and it told me to type in blanks.
  2. I asked for EmailJS, and EmailJS is built to send from the browser. Claude built it the way the service is meant to be used.
  3. The order of the answer. The warning came last, the quick fixes came first, and the real fix was phrased as "want me to?"

The habit to take away: read the last paragraph, and take the offer.

Why you can't just fix the template

The recipient has to change, because each email goes to a different employee. As far as I could find, EmailJS can't restrict which addresses that To blank accepts. So the decision has to happen somewhere the browser can't touch: a server.

The fix: four prompts, in order

I went back to the same Claude session, right after its first answer.

1. Ask the plain question. I didn't give it a security spec. I asked what I actually wanted to know.

Is this safe to put online? Could someone who isn't one of my staff use it to send emails?

It answered "partly": the sign-in was safe, the email sending wasn't, because anyone could call EmailJS from their own script with any recipient, subject and message.

2. Take the offer.

Yes, do the server version.

Now the browser only says which employee, plus the subject and message. The server checks you're staff, looks up the address, and sets the sender name and reply address.

3. Make it check its own fix.

Before I put this live, check your fix. Can anyone still send an email they shouldn't, or see anything they shouldn't?

It said outsiders were now locked out, but it found three more problems: staff could get past the hourly limit by sending many requests at once, a bad MAX_PER_HOUR value meant no limit at all, and staff could read former employees' details the page didn't show.

It also missed two things. Every staff browser still downloaded every employee's email address, and an email could go out without anything written to the log.

4. Ask for only what it missed.

Staff shouldn't be able to see employees' email addresses. And I want every email logged, even if something goes wrong.

Only send this one for the parts prompt 3 didn't catch.

The half the AI can't see

The code was done, but half the fix lives in dashboards:

  • Regenerate your EmailJS keys. The old ones were public.
  • Replace the template. The old one is still a blank form, and anyone holding the old IDs can keep using it.
  • In EmailJS account security, allow server (non-browser) API calls and require the private key.
  • Put the keys in your server function's secrets (a Supabase Edge Function, in my case) and deploy it.

Verify it worked

Don't trust the summary. Check it:

  • Signed out, view source and DevTools: no EmailJS keys or IDs anywhere.
  • Your own test page with the old keys: the send is rejected.
  • Signed in as staff, in DevTools → Network: the employee list has names but no email addresses.
  • A real staff message still arrives, from the staff tool, with replies going to the right person.
  • The send shows up in your log.

Recap

Your EmailJS public key is public by design. Your page's code is public too, whether anyone is logged in or not. So who gets the email, and who it's from, has to be decided by your server.

Paste the four prompts in order, rotate your keys, replace the template, and run the five-minute check. The full walkthrough is in the video. If your app stores everything in one Supabase row, the one-row blob fix is the companion to this one.


The app in this post is my own demo, built with fake data and intentionally insecure. The phishing email was a labelled test sent only to my own inboxes. Claude's output varies between runs. This is what happened when I tried it in November 2026.