MediumModule packFree

SendGrid

Checks the security of a Twilio SendGrid account: authenticated sender domains are validated, API keys have least privilege, Enforced TLS is on, and subusers and dedicated IPs are in the EU. Reads the SendGrid API with a read-only key through the SendGridTools module and changes nothing. Limit: glo…

By weyCC81 · Version 1.0.1 · Published 17 Nov 2026

← All tests

MP.WEY.SENDGRID.1002 SendGrid: API keys have least privilege

Severity: HighWEY.SENDGRID.Api

Each Twilio SendGrid API key should have only the scopes its application needs. An application that sends mail needs only mail.send. A leaked key with Full Access, or with scopes that create, change or delete API keys, teammates, subusers, IP access rules, SSO or the account's own sign-in, lets an attacker take over the account: create keys of their own, add teammates, lift the IP allow list and send phishing as your domains.

The test gives one result per API key. A key fails when it has Full Access, any scope that manages access to the account, or more scopes than MaximumScopes (60 by default). Needs the API key scope api_keys.read. The key Maester connects with is checked too, so give it read scopes only.

Set the limit in maester-config.json, or leave out a key you accept by its ID:

{
  "TestSettings": [
    { "Id": "MP.WEY.SENDGRID.1002", "Parameters": { "MaximumScopes": 20 } },
    { "Id": "MP.WEY.SENDGRID.1002.<api key ID>", "Enabled": false }
  ]
}

Remediation action

  1. In SendGrid, open Settings > API Keys and the key.
  2. Change it to Restricted Access and give it only what its application uses, for example Mail Send.
  3. If the key is not used any more, delete it. If it may have leaked, delete it and create a new one.
  4. Keep Full Access keys for none or one break-glass purpose, stored in a vault.

See API keys and API key permissions.

%TestResult%

Install
Install-MtPack weyCC81/ch.alweys.maester-pack-wey/sendgrid

Assumes Maester is installed. New to Maester? Get started.

Next: connect and run
Connect
Connect-Maester -Service WEY.SENDGRID.Api -ServiceSetting @{ ApiKey = (Read-Host -AsSecureString 'SendGrid API key') }
Run
Invoke-Maester -Pack WEY.SENDGRID -SkipBuiltIn