# Events and detections

> The event types the SDK sends, what each one detects, its severity and when it becomes an alert in the dashboard.

URL: https://docs.proteside.com/en/docs/integration/events

The SDK sends the dashboard two kinds of events: **detections** (something suspicious happened on the page) and
**telemetry** (pageviews, inventory, payment validations). Detections become alerts; telemetry feeds the **Scripts**
inventory, **SDK Health** and **Payment Integrity**.

## How an event becomes an alert
* **The dashboard sets the severity**, not the SDK. The severity reported by the SDK is recorded on the alert as
  "Severity reported by the SDK". The tables below show the base severity in the dashboard.
* **Repeated events don't create new alerts.** While there's an open alert for the same problem (for example, the
  same script or the same exfiltration destination), new occurrences are added to the existing alert. If the alert
  was already resolved, a new occurrence opens a new alert.
* **The notification goes out only when the alert is created.** Repeated occurrences don't notify again.
* **Scripts written in the page's HTML** show up in **Scripts** with a note that they keep loading from the HTML. To
  stop them, remove the tag at the source (HTML or theme).

See how to handle alerts in [Alerts](https://docs.proteside.com/en/docs/guide/alerts).

## Page baseline
Right after the page loads, the SDK establishes the page baseline. Scripts present at that moment go into the
inventory and need your review in **Scripts**.

## Scripts
| Event                   | What it detects                                                                                | Severity       | Alert |
| ----------------------- | ---------------------------------------------------------------------------------------------- | -------------- | ----- |
| `SCRIPT_INJECTION`      | A new executable script appears outside what the page already had.                             | high, adjusted | yes   |
| `SCRIPT_MODIFIED`       | A known script reappears with different content.                                               | high, adjusted | yes   |
| `SCRIPT_BLOCKED`        | A script matched a blocking rule and was stopped.                                              | high           | yes   |
| `GTM_CONTAINER_BLOCKED` | A Google Tag Manager container or a `gtag.js` tag outside the **Allowed GTM containers** list. | high           | yes   |

**Adjusted severity:** for `SCRIPT_INJECTION` and `SCRIPT_MODIFIED`, the dashboard raises it to **critical** when the
vendor is flagged as a threat in the catalog, lowers it to **low** when it's a cataloged vendor, and uses **medium**
for first-party scripts and inline scripts. In all other cases, it stays **high**.

## Customer data
| Event                    | What it detects                                                 | Severity | Alert |
| ------------------------ | --------------------------------------------------------------- | -------- | ----- |
| `KEYLOGGER_DETECTED`     | A script starts capturing what is typed into a sensitive field. | critical | yes   |
| `EXFILTRATION_ATTEMPT`   | Sensitive customer data is sent to an untrusted destination.    | adjusted | yes   |
| `WEBSOCKET_EXFILTRATION` | A `WebSocket` connection is opened to an untrusted destination. | critical | yes   |
| `FIELD_ACCESS`           | A script registered a listener on a sensitive field.            | info     | no    |

The SDK sends only the names of the patterns it found, never the content sent.

**Adjusted severity:** exfiltration is **critical** when the destination is a vendor flagged as a threat or when it
involves card or ID document data; it's **low** when the destination is a payment processor or a cataloged
vendor; in all other cases, it's **high**.

## Forms, iframes and overlays
| Event                      | What it detects                                                                                                                                                    | Severity | Alert |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------- | ----- |
| `FORM_ACTION_HIJACK`       | A form's `action` attribute changed, including on forms created later.                                                                                             | critical | yes   |
| `OVERLAY_DETECTED`         | An element is positioned over a sensitive field or the payment area.                                                                                               | high     | yes   |
| `IFRAME_REPLACED`          | The address of a known payment provider's iframe changed.                                                                                                          | high     | yes   |
| `IFRAME_UNEXPECTED`        | A payment iframe outside the **Expected iframe origins**, or an iframe overlaid on an expected iframe. With the list filled in, iframes outside it raise an alert. | high     | yes   |
| `CARD_FIELD_OUTSIDE_VAULT` | A card field you can type into on the main page, outside the provider's iframe. Fill in **Expected iframe origins** to turn it on.                                 | high     | yes   |

## Payment
| Event                 | What it detects                                                                                                                                                                             | Severity | Alert |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ----- |
| `PIX_TAMPERED`        | The displayed Pix code changed to one that doesn't match the reference, or the recipient isn't among the trusted ones.                                                                      | critical | yes   |
| `BOLETO_TAMPERED`     | The digit line changed, or the bank isn't among the trusted ones.                                                                                                                           | critical | yes   |
| `CRYPTO_ADDRESS_SWAP` | The crypto address changed, or isn't among the trusted ones.                                                                                                                                | critical | yes   |
| `UPI_TAMPERED`        | The UPI code changed, or the VPA isn't among the trusted ones.                                                                                                                              | critical | yes   |
| `QR_TAMPERED`         | The code for another QR-based method (PayNow, PromptPay, DuitNow, QR Ph, HK FPS, Transferencias 3.0, CoDi or QR wallet) changed, or a QR code image started coming from a different domain. | critical | yes   |
| `AMOUNT_TAMPERED`     | The code's amount differs from the one passed to `expectPayment()`, or the same recipient appeared with a different amount.                                                                 | critical | yes   |
| `CLIPBOARD_HIJACK`    | The content copied to the clipboard looks like a payment code and doesn't match the reference.                                                                                              | high     | yes   |
| `PAYMENT_VALIDATED`   | A payment code was read and validated. Feeds **Payment Integrity**.                                                                                                                         | info     | no    |

Details in [Payment integrity and Pix](https://docs.proteside.com/en/docs/integration/payment-integrity).

## Environment and installation
| Event                        | What it detects                                                                                                                                                                  | Severity | Alert |
| ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ----- |
| `SERVICE_WORKER_BLOCKED`     | A registered service worker outside the **Allowed service workers**. With the list filled in, service workers outside it raise an alert.                                         | high     | yes   |
| `SERVICE_WORKER_REGISTERED`  | An allowed service worker was registered.                                                                                                                                        | info     | no    |
| `INSTALLATION_ORDER_WARNING` | There are scripts before the snippet in the `<head>`. The alert itself offers **Stop warning for this store**. See [Troubleshooting](https://docs.proteside.com/en/docs/integration/troubleshooting#ordem-de-instalacao). | medium   | yes   |

## Telemetry
These events never become alerts:

| Event                  | When it's sent                                                                     |
| ---------------------- | ---------------------------------------------------------------------------------- |
| `PAGEVIEW`             | On every page load and every `Proteside.pageChanged()`.                            |
| `BASELINE_CALIBRATING` | When the SDK starts establishing the page baseline.                                |
| `BASELINE_CLASSIFIED`  | With the page's script inventory (address, content hash, size and classification). |
| `BASELINE_ESTABLISHED` | When the page baseline is established.                                             |

## Generated by the dashboard
Some alerts don't come from an SDK event, but from server-side checks:

| Alert                       | Source                                                                                                                              | Severity |
| --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | -------- |
| `SCRIPT_INTEGRITY_MISMATCH` | An authorized script's content changed compared to the approved hash.                                                               | high     |
| `HEADER_CHANGED`            | A security header on the payment page changed value.                                                                                | medium   |
| `CSP_VIOLATION`             | A CSP report sent to Proteside points to a host outside the inventory. See [CSP and headers](https://docs.proteside.com/en/docs/integration/csp).                            | low      |
| `SDK_SILENT`                | A domain with history stopped receiving real sessions. The alert shows up within a day and resolves itself when traffic comes back. | medium   |

## Next steps
* [Alerts](https://docs.proteside.com/en/docs/guide/alerts)
* [Configuration](https://docs.proteside.com/en/docs/integration/configuration)
