---
product: "AG Studio"
title: "Security"
description: "AG Studio exposes security tools and parameters so an application can meet its own security requirements."
framework: angular
version: "3.1.0"
related:
    - title: "Compatibility"
      url: "https://www.ag-grid.com/studio/archive/3.1.0/angular/compatibility/"
    - title: "Supported Browsers"
      url: "https://www.ag-grid.com/studio/archive/3.1.0/angular/supported-browsers/"
llms: "https://www.ag-grid.com/studio/archive/3.1.0/llms.txt"
---

# Security

AG Studio exposes security tools and parameters so an application can meet its own security requirements.

## Content Security Policy (CSP)

The basic information on Content Security Policy can be found on the [MDN Web Documentation](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) website and will cover the necessary information on the subject. Studio works with CSP, but some basic configuration is necessary to have your application load correctly. The minimum set of CSP rules for Studio is described below.

### style-src

[Themes](https://www.ag-grid.com/studio/archive/3.1.0/angular/theming/) work by injecting CSS styles into the DOM when Studio initialises. By default this requires a `style-src 'unsafe-inline'` directive in your CSP.

However, you can avoid this requirement using the `styleNonce` Studio property as shown below. The `styleNonce` property should be set to a random value that changes with each page load.

```ts
<ag-studio
    [styleNonce]="styleNonce"
    /* other studio properties ... */ />

this.styleNonce = "416d1177";
```

This sets the nonce attribute on the style tag, so Studio will now work with the CSP directive `style-src 'nonce-416d1177'` without the need for `'unsafe-inline'`.

CSP nonces are global to a page, so when a page has multiple Studio instances, all instances must have the same `styleNonce` set.

### img-src

The `img-src data:` directive is required because Studio uses data urls to embed SVG images in CSS files.

The Image widget's image URL, whether typed as a static URL or supplied from bound data, is requested by the browser of every viewer of the dashboard. Anyone who can set that URL can therefore cause each viewer's browser to contact the host it names. To restrict where images may be loaded from, add an `img-src` directive that lists only the image hosts your application allows, for example `img-src 'self' data: https://images.example.com`. An image whose URL is not allowed by the directive is blocked by the browser and not shown.

### font-src

If you use the `loadThemeGoogleFonts` Studio property, fonts will be loaded from the Google font CDN, which requires the `font-src fonts.gstatic.com` directive.

### Example Locked-Down CSP

This example CSP below allows Studio to be run in a secure manner:

```html
<meta http-equiv="Content-Security-Policy"
      content="default-src 'self'; style-src 'self' 'nonce-123xyz'; img-src 'self' data:">
```

It assumes:

1. The application loads assets from the same server (`'self'`)
2. You are not using `loadThemeGoogleFonts`
3. The random string passed to `styleNonce` on this page load is "123xyz"
4. Image widgets only show images served from the same server; add any other allowed image hosts to `img-src`

## Trusted Content

Some Studio inputs are rendered into the page, so they are either restricted or must come from a trusted source:

- **Link URLs** on [Text and Image Widgets](https://www.ag-grid.com/studio/archive/3.1.0/analysts/static-content-widgets/) must be relative URLs or absolute URLs using `http:`, `https:` or `mailto:`. Any other URL is rejected and is not rendered as a link. To apply your own rule instead, set a `validateLinkUrl` function in the `options` of the `text` and `image` [Widget Overrides](https://www.ag-grid.com/studio/archive/3.1.0/angular/widget-configuration/#widget-overrides). It is called in place of the built-in check, so it must reject any URL that a browser would run as script, such as `javascript:`.
- **String icons** are parsed as HTML. This applies to the `icon` on a [Custom Widget](https://www.ag-grid.com/studio/archive/3.1.0/angular/custom-widgets/#creating-a-custom-widget), a [Widget Override](https://www.ag-grid.com/studio/archive/3.1.0/angular/widget-configuration/#widget-overrides) and an [AI Prompt Starter](https://www.ag-grid.com/studio/archive/3.1.0/angular/ai-chat-features/#suggesting-prompts). Supply string icons only from trusted sources, or use a CSS class name or an SVG URL instead.
- **Cell renderers** returned from [`createCellRenderer`](https://www.ag-grid.com/studio/archive/3.1.0/angular/widget-configuration/#cell-renderers) that are plain functions returning a string are rendered by AG Grid as HTML. Escape any untrusted values in the string, or return a DOM element instead. Values from [Linked Fields](https://www.ag-grid.com/studio/archive/3.1.0/angular/widget-configuration/#linked-fields) reach a cell renderer raw, like any cell value, so escape them in the same way.

## Security Vulnerability Testing

Applications may be required to pass an Application Security Test prior to being put into production. If your application is using AG Studio, you will want to make sure that AG Studio has also been tested for security vulnerabilities.

AG Studio is tested for a wide variety of security vulnerabilities using the [SonarQube](https://www.sonarqube.org/) automatic security testing tool. SonarQube performs testing using a number of security rules, covering well-established security vulnerability standards such as CWE, SANS Top 25 and OWASP Top 10. For more details please refer to the section on [Security-related Rules](https://docs.sonarqube.org/latest/user-guide/security-rules/#header-2).

## Security Contact

At AG Grid, we take security seriously. If you believe you've discovered a vulnerability, security issue, or have any concerns related to the security of our libraries or websites, we encourage you to contact us directly.

Please email us at [security@ag-grid.com](mailto:security@ag-grid.com) with details of the issue. We appreciate responsible disclosure and will work quickly to investigate and resolve any confirmed concerns.
