1. Spreadsheet docs
  2. Developers

Security and hosting

Keep workbook data on your site, choose the options for untrusted files, and serve 8sheets with working headers and a Content Security Policy.

8sheets runs entirely in the user's browser. Files are read and written on the device, and the library makes no requests of its own beyond loading its own files from the folder it was served from: there is no telemetry, no licence check and no account. This page covers the few features that can reach other sites, how to turn them off, and how to serve 8sheets with strict headers.

A locked-down embed

For an app that shows the spreadsheet next to business data, or that opens files from people you don't control, these options keep everything on your site:

JavaScript

import { mountWorkbook } from '@8sheets/core';

const wb = await mountWorkbook(document.querySelector('#sheet'), {
  onlineFeatures: false,   // nothing in a workbook can reach another site
  scripts: false,          // no Automate tab, no scripts run in your page
});

React

import { Sheet } from '@8sheets/react';

const options = { onlineFeatures: false, scripts: false };

export function SecureWorkbook() {
  return (
    <div style={{ height: 560 }}>
      <Sheet options={options} onInvalidOperation={(e) => console.info('refused', e.action, e.reason)} />
    </div>
  );
}

Vue

<script setup>
import { Sheet } from '@8sheets/vue';

const options = { onlineFeatures: false, scripts: false };
</script>

<template>
  <Sheet :options="options" style="height: 560px" @invalid-operation="(e) => console.info('refused', e.action, e.reason)" />
</template>

Angular

import { Component } from '@angular/core';
import { SheetComponent, SheetEventPayload, SheetOptions } from '@8sheets/angular';

@Component({
  selector: 'app-secure-workbook',
  imports: [SheetComponent],
  template: `<eight-sheet class="grid" [options]="options" (invalidOperation)="refused($event)" />`,
  styles: `.grid { height: 560px; }`,
})
export class SecureWorkbook {
  options: SheetOptions = { onlineFeatures: false, scripts: false };

  refused(e: SheetEventPayload) {
    console.info('refused', e['action'], e['reason']);
  }
}

What can reach another site

With the default onlineFeatures: true, these features can make requests to addresses a workbook names:

  • Get Data From Web and data sheets bound to a web address,
  • the WEBSERVICE function, and pictures from IMAGE and SPARK_IMAGE,
  • the AI features,
  • File > Share with a collaboration server on another site.

A workbook from an untrusted source could use a formula such as WEBSERVICE or IMAGE to send cell values to a server in its address. onlineFeatures: false leaves those commands out and makes the features refuse to run: cells that use them show #BLOCKED!, no redirect is followed, and cell data never leaves for another site. Addresses on your page's own site keep working. The setting is the page's, so it covers every workbook on the page.

Scripts and macros

  • VBA in .xlsm files is kept in the file and saved unchanged, but never run.
  • Scripts are JavaScript that a user types or records on the Automate tab. They run in your page, with its rights: they could read anything your page can. Nothing runs from an opened file. scripts: false removes the Automate tab, View > Macros and Record Actions, and refuses to run scripts.
  • Custom functions and cell buttons run code your page registered (wb.functions.define, registerButtonAction). A file stores only formula text and action names, so opening a workbook can never bring code of its own.

Protection is not encryption

Sheet and workbook protection prevent accidental changes, as in Excel; they don't hide data from anyone who has the file. Only File > Password to Open encrypts a workbook, with the same method as Excel. Read-only views built with events are a user-interface choice; enforce access rights on your server.

Collaboration

Real-time editing works through a collaboration server that you run yourself: it comes with the source licence (tools/collab-server.mjs). Name it with the collabServer option. The hosted server at collab.8sheets.com serves the 8sheets app only and does not accept embedded workbooks. See Users, comments and collaboration.

Headers

HeaderValueWhy
Content-Type for .jstext/javascriptThe Workers are started as ES modules.
Cross-Origin-Opener-Policysame-originWith the next header, makes the page cross-origin isolated, so 8sheets can use SharedArrayBuffer. Optional: it runs without.
Cross-Origin-Embedder-PolicycredentiallessNot require-corp, which blocks =IMAGE() pictures from other sites.

Serve 8sheets from your own origin. Browsers start Workers only from the page's own origin, so a copy on a CDN with another domain could not open or save files.

Content Security Policy

This policy was tested with a mounted workbook in Chromium: the app draws, and opens and saves files.

Content-Security-Policy:
  default-src 'self';
  script-src 'self';
  style-src 'self' 'unsafe-inline';
  img-src 'self' data: blob:;
  font-src 'self' data:;
  connect-src 'self';
  worker-src 'self';
  object-src 'none';
  base-uri 'self'
  • style-src 'unsafe-inline' is required. 8sheets scopes its stylesheet to the workbook element and sets inline styles on its own elements; without it the layout falls apart.
  • script-src needs nothing beyond 'self' for the app and its Workers. 'unsafe-eval' isn't needed. Scripts on the Automate tab are compiled from the user's text and can't run without it, which is one more reason to set scripts: false under a strict policy.
  • Add sources for the features you allow: your collaboration server in connect-src (wss://collab.example.com), and the sites of IMAGE pictures in img-src, if onlineFeatures stays on.

Checklist

  • Serve the package from your own origin, with .js as JavaScript.
  • Send COOP same-origin and COEP credentialless if you want cross-origin isolation.
  • Set onlineFeatures: false when workbooks hold data that must not leave your site or come from untrusted sources.
  • Set scripts: false unless your users need scripts.
  • Use your own collaboration server, if any, and give it in collabServer.
  • Check access on your server: anything the browser has, the user has.