I'm trying to hunt down a possible leak on my .env file. Someone gained access to my SendGrid API key and of-course went full ham. Hopefully, not too much damage is done. I revoked the key so they can't continue spamming and changed all my other keys (DB etc).
My concern is if and how they gained access to the .env file. My production environment is on an EC2 box which only I have access via SSH with a private key and locked down to IP. HTTP & HTTPS are open to the public.
The .env file is set to APP_debug=false so nothing should have been printed out when an exception was thrown.
Checking the mail logs, an email was sent 5 days ago with a subject line containing the email settings (Host, Port, apikey, and my company email address), along with some other emails with a subject line of "SMTP test" before going crazy (10000 mails) requesting the verification of a BDO bank account. From what I can determine the attack was aimed at the Philippines as BDO is a local bank to the Philippines.
The .env file is in the root folder of Laravel and as I understand this should not be accessible to the public as it is only the public folder that can be accessed.
The bizarre part is have 2 keys in the env, yet it was only the one that was abused.
My DB is locked down on access to specific IPs so nothing has been accessed there. My S3 bucket also hasn't had any unusual connections.
I am worried because, for the life of me, I cannot determine if the env file leaked, my server was hacked, I left the key lying around (unlikely) or Sendgrid leaked something.
Reading around Sendgrid doesn't seem to have a great reputation and following this, I am looking into alternatives for mail sending.