share safely

How it works

Summary

  • Skape ensures your data is secure by ensuring that all authorization and authentication happens only in trusted code - either the Skape platform or your browser.
  • An app keeps a user's data in one or more spaces - each space is a sandboxed database that's separate from all other data for other apps or users
  • You can choose to share a space with other users
  • You can give users full access to all data in the space, but usually you'll choose to assign Roles to users with access to a space and Grant specific users access to the space.

How Skape Apps work

Skape apps are web apps, so they run in a browser - when you install them on your laptop or phone, they are able to be responsive like local apps because they can run locally, but they still run inside a hidden browser.

To allow multiple people and devices to see data for an app, the data for apps is stored in skape's servers in its own database. Skape calls the particular data for a particular app and set of users a space. The app decides which spaces to make and what to call them (for a packing app, say, "Family trips" and "My own lists").

To use the data, apps call the skape servers and pass along information about the current user and app, as well as the database request - the server then validates that information (as discussed below in the security section) and runs the request against the space.

More details

The goal is that Skape apps should be built up out of standard parts, so we have kept custom APIs/etc to a minimum. Skape apps are similar to apps built on firebase/supabase type platforms in that the app is defined as a set of html & js files that runs in the user's browser and the app talks to a backend for the database, allowing them to sync between devices.

The Skape platform serves these apps with a PWA wrapper so they can be installed on user's phones/laptops, and provides a basic service worker - apps can extend that service worker themselves if they want to (eg to allow the apps to work completely offline). Skape has a simple client library that handles important functionality like ensuring the user is signed in, starting invite requests, retrieving blobs, providing a client for the db, etc...

Each skape space's database is a sqlite file, and the app defines a set of SQL queries at app creation time that can run against the database, as well as a set of migrations to keep the app up to date. So the javascript app running in the client calls the client sdk with the name of the query to run and the query's parameters, and the query is run by the backend.

A major different from firebase/supabase is the space model - every space is its own fresh database, and only its owner and the people they invite can open it. This is how databases can be secure by default.

Below we show a minimal app - this is what an agent (or developer) would upload to the service.

skape.json
// skape.json is a manifest file that defines metadata about the app
{
  "title": "Hello world",
  "sdkVersion": 2,
  "scripts": ["app.js"],
  "tests": ["tests.js"],
  "stylesheets": ["style.css"],
  // Skape runs these db migrations before users are able to access the app, so apps don't have to worry about it
  "migrations": [
    "CREATE TABLE greeting (id INTEGER PRIMARY KEY, name TEXT NOT NULL) STRICT"
  ],
  // These are the sql queries that apps are able to 
  "queries": {
    "getName": {
      "sql": "SELECT name FROM greeting",
      "roles": ["host"]
    },
    "saveName": {
      "sql": "INSERT OR REPLACE INTO greeting (id, name) VALUES (1, :name)",
      "roles": ["host"]
    }
  }
}
app.js
// app.js is the script that was specified by skape.json, so it'll be run in the user's browser when the app is visited.
const skape = await SkapeClient.createClient();
const app = document.getElementById("app");

if (skape.user === null) {
  app.innerHTML = `<button>Sign in</button>`;
  // skape.SignIn() starts a process whereby users go to a skape controlled page to log in - until the user
  // does so, they won't be able to use the database.
  app.querySelector("button").onclick = () => skape.signIn();
} else {
  app.innerHTML = `<h1>Hello, who are you?</h1><form><input placeholder="Your name" required> <button>Save</button></form>`;
  const [hello, form, input] = app.querySelectorAll("h1, form, input");

  // skape.db.run() is how apps can run the SQL queries defined in skape.json
  const { rows } = await skape.db.run("getName");
  if (rows.length > 0) hello.textContent = `Hello, ${rows[0].name}`;

  form.onsubmit = async (event) => {
    event.preventDefault();
    await skape.db.run("saveName", { name: input.value });
    hello.textContent = `Hello, ${input.value}`;
  };
}

Security

While agents can allow people who haven't studied programming to build app, it comes with risks - how can we trust that AI built software does not have vulnerabilities?

We don't. Instead, when you write a program on the Skape platform, Skape treats it as untrusted and restricts what it can do so that Skape itself controls all access to the data - it does this by leveraging standard browser technology (the same technology that secures important websites you use every day - like your bank.)

Even if a hacker wrote an app intentionally to steal your data, if it's on the Skape platform, should not be able to expose your data on the internet.

When you use skape apps, you don't log into each individual app, you log into Skape itself. Skape then gives your browser a cookie that verifies who you are, and that cookie is not accessible to the app running in your browser - it's only shared between the Skape server and the browser. When your app talks to the Skape servers, your browser attaches the cookie you got from Skape to that request as well as the URL of the app that's running and Skape then knows what the current user is (from the cookie) and the app that's running (from the URL). The untrusted code (the app) can't interfere with that.

So the app can't expose your data on the internet because it only has access to the data when running in a browser where you've logged in - the app never handles any sensitive login credentials at all, and thus can't expose your information.

Another part of this protection is network access - in the worst case, a malicious app could let you log in to skape and then send your data out over the network and leak it. However, by default Skape apps cannot access the internet, so this is prevented. If an app does have a reason to access another site (eg to work with your calendar stored in google), they have to request access to specific sites when they are created, and that is visible to users. Take a look at the sites a particular app requests access to on the app details page, and if you have questions, reach out to support and we'll take a look.

Sharing: roles & permissions

To allow multiple users to access the same app, there are two layers of protection:

Consider a grant to be like a keycard that lets you into a building - anyone walking around the building has to have a keycard and if you see someone without a keycard you immediately know something is wrong. You then have to use your keycard at specific doors to get into locked spaces, with different keycards opening different doors depending on what that person has access to - those are roles.

Roles are something you define when creating apps. Grants are something you create when using the app by inviting users to the app.

Let's take the example of a blogging app. Here's what the roles might be for that app:

When building apps, your agent will work with you to define the roles for your app. Then, when using the app, you'll be able to invite users to your space and that will create grants for them. Note that if you want to share different data with different users, there are multiple ways to do that. One way would be to create multiple spaces with different users invited to each space, and another would be to define roles where users only have access to certain data. What works best for your particular application is something you should discuss with your agent, but please reach out to support if you have questions or need clarification.

Going back to our worst case scenario analysis that we started in the Security section above, how does Skape prevent malicious users and app developers (or mistakes in vibe coded apps) from getting access to your data after you start sharing? Again, we treat the app as untrusted, and the app itself cannot create grants - when you want to invite a user to a space, that has to happen inside of the Skape platform, not inside of the app. The app sends you to a page where you put in the email address of the person you want to invite to that space, as well as the role for that user. So an app can't automatically add other users (like the app's creator!) to a space without you knowing.

Unfortunately, the Skape platform cannot guarantee that roles are correct - they are defined by the agent itself, and there's not really a way for the skape platform to understand who should have access to what data. We've tried to make them as simple to review as possible, so mistakes should be obvious to your agent but we suggest asking your agent to tell you exactly what each role has access to and to think like an attacker and look for vulnerabilities. We've given this instruction to agents in our documentation for agents, so your agent should proactively do it.

One restriction of the Skape platform (for now!) is that all users must be logged in to use data from a space. This means that for example a fully public blog where anyone can read it is not possible to build on Skape. We are considering ways to allow a space's data to be readable by anyone - please send feedback to support if you have specific apps you'd like to build that aren't possible today because of the lack of support for non-logged in users.

More details

To allow for multiple users in the database in a way that Skape can control without giving up performance, Skape has a novel but simple system - apps define which roles can run which queries, and it assigns the values for some parameters at the system level rather than let the app set them.

Here's an example app - hello-world-multi which is a simple demo app allowing multiple users to interact. Here's the skape.json file that shows how roles are used to control who can do what

skape.json
{
  "title": "Hello world (multi)",
  "sdkVersion": 2,
  "scripts": ["app.js"],
  "tests": ["tests.js"],
  "stylesheets": ["style.css"],
  "roles": {
    "friend": { "description": "Saves their own name and sees everyone else's" },
    "guest": { "description": "Sees everyone's names but can't add one" }
  },
  "migrations": [
    "CREATE TABLE names (user_id TEXT PRIMARY KEY, name TEXT NOT NULL) STRICT"
  ],
  "queries": {
    "getMyName": {
      "sql": "SELECT name FROM names WHERE user_id = :skape_user_id",
      "roles": ["host", "friend"]
    },
    "saveMyName": {
      // The fact that skape_user_id is added by the server (not the client) means that 
      // users can't edit other user's info, even if they
      // were to modify what goes over the wire to the server.
      "sql": "INSERT INTO names (user_id, name) VALUES (:skape_user_id, :name) ON CONFLICT (user_id) DO UPDATE SET name = excluded.name",
      // Note that the roles list here does not include "guest" - that means 
      // users with the role guest can't save their name to the db
      "roles": ["host", "friend"]
    },
    "listOtherNames": {
      "sql": "SELECT user_id, name FROM names WHERE user_id != :skape_user_id ORDER BY name LIMIT 100",
      "roles": ["host", "friend", "guest"]
    },
    "removeName": {
      "sql": "DELETE FROM names WHERE user_id = :userId",
      // Only hosts are listed here, so they are the only ones who can remove names
      "roles": ["host"]
    }
  }
}