Security
An app can come from anyone, so Ghost does as much as possible to keep publishers’ data safe, even when an app has a bug or isn’t trustworthy.
What Ghost does
- Never runs app code on Ghost’s servers. Apps run on separate servers.
- Runs apps in a sandbox. Your app’s page runs in a sandboxed iframe inside Admin, which is designed to stop it from reading the rest of Admin or changing where Admin goes. On some sites, code an app writes to the site’s posts can get around it (see While apps are in beta).
- Checks what apps ask for. Each app declares the scopes it needs, and an Administrator approves them before the app opens, and again when it asks for more (see Access). A request from an app’s page goes through only when an approved scope covers it and the role of the person using the app allows it. Ghost enforces this itself, whatever the app’s code does. Any app can read the site’s public details, such as its title and logo, which Ghost shares with anyone.
- Doesn’t share publishers’ passwords or API keys with apps. When an app opens, Ghost issues a token limited to the scopes the site approved. Ghost Admin holds the token and makes the app’s requests with it, as the signed-in person and without their sign-in cookie. The app’s code never sees the token, and Ghost refuses the app’s requests once the app is uninstalled, or the person signs out or is suspended. If the person stops being the Owner or an Administrator, the app closes the next time Ghost Admin renews its token, and until then their new role limits what it can do.
- Asks before bigger changes apply. Bigger changes to an app need approval first.
- Checks an app comes from its developer. Ghost installs only a signed manifest, remembers the key that signed it, and challenges the app’s server before installing or opening it (see App identity).
What the sandbox allows
Your page can run its own code, submit forms to its own server, keep its own data in the browser, open new windows, and download files.
Windows your app opens keep the same sandbox.
The sandbox blocks changing Admin’s URL, showing the browser’s alert and confirm dialogs, and using the camera, location, or fullscreen.
What’s up to you
- Give your app a domain that serves nothing else, such as
calendar.example.com, notexample.com/calendarnext to your website. Every page on that domain that opens inside Ghost, including windows and frames your app opens, can read and change the site’s posts as the person using the app (more in Deployment). - Only add code from services you trust to your app’s page, such as chat widgets or analytics. It runs with the same access as your app.
- Keep API keys on your server, never in your page.
- Anyone can call your server the way your page does. Ghost doesn’t verify which site or person a request comes from (see Deployment).
- If your app’s server downloads links people give it, such as a podcast feed URL, only allow public
httpsURLs. Otherwise someone can give it a private address, likelocalhostor your host’s internal network, and your server fetches it for them. - Set an expiration date for anything your server keeps for a site, or delete it when the site asks. Ghost doesn’t tell your server when a site uninstalls your app yet (more in App lifecycle).
Your app’s keys
Your app’s identity key and backend key prove it’s yours (see App identity). To keep them safe:
- Keep the production identity key on your computer or in a CI job’s secrets, away from your app’s running server, with a backup outside your app’s folder, such as a password manager
- Give your app’s server only the backend key, in the host’s secret settings
- Keep
.ghost-app/and.dev.varsin.gitignore, and never commit a key, paste it into a chat, or put it in your page - If a key leaks or gets lost, follow Losing or leaking a key
While apps are in beta
Current limitations (see the Roadmap):
- Apps act as the person using them. Ghost records an app’s changes under that person’s name. An app approved for
post:editcan publish whenever someone who can publish has it open. - Code an app writes can run as whoever views it. Apps can add HTML and scripts to posts and pages, and that code runs for everyone who reads them, including signed-in members. On sites where Ghost Admin shares the site’s address (
yoursite.com/ghost), that code can also reach more of Ghost than apps can. That includes most self-hosted sites, and Ghost(Pro) sites without a custom domain. It acts as whoever uses the app, previews the post in Ghost Admin, or views the site while signed in to Ghost. Installing an app means trusting its developer. - Apps can read staff users’ email addresses, along with their names and roles: With
user:browse, and as the authors of any post or page they read. Ghost will stop sending the email addresses to apps. - An app that’s already open can keep running for up to about 50 minutes after it’s uninstalled. Ghost refuses its requests to Ghost from then on. If it’s open in another tab or for another staff user, it closes the next time it calls Ghost, or when someone comes back to its tab. One that doesn’t call Ghost closes when Ghost Admin next renews its token, within about 50 minutes. Until it closes, its page keeps running there, and still reaches its own server and anything else outside Ghost. An app that’s waiting for approval closes the same way, and shows that it needs approval.
- Some access outlasts uninstalling. Anything the app wrote to the site’s posts and pages stays, including HTML and scripts. Preview links to unpublished posts and pages the app has read keep working.
- Ghost never asks for a password, or a code it emailed, inside an app. Anything inside an app that asks for one isn’t Ghost.
- Public sites need to run in production mode. Development mode turns off Ghost’s protection against fetching private addresses, for apps and everything else Ghost fetches.