# What security hardening measures protect enterprise Salesforce integrations from unauthorized access and data breaches?

**Topic:** Integration · **Difficulty:** Medium · **Tags:** Integration, Security Hardening, API Protection

Read it on the site: https://www.forcechallenges.com/interview-questions/what-security-hardening-measures-protect-enterprise-salesforce-integrations-from-unauthorized-access-and-data

## Answer

**Basics:** Integrations are high-value targets because they run unattended with broad access. Security is layered: who the integration is, what it can do, how its secrets are stored, how requests are verified, and how misuse is detected.

**How it works (controls):**
1. Identity: a dedicated integration user per system with the "API Only User" permission and a minimal permission set (no UI login, no admin rights).
2. Authentication: OAuth with JWT Bearer or Client Credentials rather than stored passwords; narrow scopes; Connected App (or External Client App) policies: admin-approved users, IP relaxation settings, session and refresh-token policies.
3. Network: TLS 1.2 or higher; IP allowlists via login IP ranges or connected app policy; mutual TLS with a certificate in a Named Credential where the partner supports it.
4. Secrets: Named Credentials and External Credentials keep secrets out of code; never in plain custom settings or custom labels.
5. Inbound integrity: Apex REST endpoints validate signatures and inputs.
6. Monitoring: Event Monitoring (Shield) for login and API events, plus alerts.

**Advanced / deep dive:** Enforce sharing and field security in Apex REST (use `with sharing`, `WITH USER_MODE` queries or `Security.stripInaccessible`) because API users with broad access can otherwise leak data. Verify webhooks with an HMAC signature using a shared secret via `Crypto.generateMac`. Rotate keys and certificates, expire unused connected apps, and review "API Access Control" (restricts which connected apps users may use; verify availability) and OAuth usage reports. Protect data at rest with Platform Encryption where required. Reduce blast radius with separate users per integration so one compromised credential does not expose all.

**Code / config example:**
```apex
@RestResource(urlMapping='/webhook/orders')
global with sharing class OrderWebhook {
    @HttpPost
    global static void receive() {
        RestRequest req = RestContext.request;
        String sig = req.headers.get('X-Signature');
        Blob mac = Crypto.generateMac('HmacSHA256', req.requestBody, Blob.valueOf(Secrets.get('hook')));
        if (sig != EncodingUtil.base64Encode(mac)) {
            RestContext.response.statusCode = 401; return;
        }
        // parse and enqueue processing
    }
}
```

**Hidden gotchas & must-remember points:**
- Scope `full` or an admin integration user is a common over-grant.
- Custom settings and custom metadata are not a safe place for secrets unless protected in a managed package.
- Signature checks must use the raw body, not re-serialized JSON.
- Expired certificates cause silent outages; track expiry.
- IP allowlisting is not enough; combine with authentication.

**Best practice:** Use one least-privilege user per integration, Named Credentials for secrets, verified inbound requests and continuous monitoring.

---
Source: ForceChallenges · last updated 2026-11-02
