<!-- Canonical HTML: https://docs.didro.ai/sap-ui-automation/security -->

# Security and data handling

This page is for the people who decide whether an agent may work in SAP:
SAP security, Basis and data protection. It says what runs where, what
leaves the machine, what is written to disk, and what the agent can do
under each setting.

To report a vulnerability, see
[SECURITY.md](https://github.com/DidroAI/sap-ui-mcp/blob/main/SECURITY.md).

## In short

- **It runs locally.** The server is a process on the user's machine,
  started by the user's MCP client (Claude Code, Codex, Cursor, ...). There
  is no hosted service and no account.
- **No telemetry, no analytics, no update checks.** It sends nothing to
  Didro or to any other third party.
- **It talks only to what the user already uses:** SAP GUI on the same
  machine, Chrome through its local DevTools endpoint (a Chrome window the
  server starts, the user's Chrome or Edge, or the user's Chrome through
  the extension's local port),
  and, with the network reader only, the SAP system or router SAP GUI is
  already connected to.
- **Screen content goes to the MCP client, and from there to the model
  provider the user chose.** That is the only path off the machine, and
  the user controls it.
- **No credentials.** It never logs on, never stores a password, never
  types into a password field. It works in sessions the user opened. The
  optional Chrome extension is the exception the user chooses: it keeps
  the passwords of the systems registered in it in the system's keychain
  and types them into SAP's logon page itself; the server and the agent
  never see them
  ([extension/PRIVACY.md](https://github.com/DidroAI/sap-ui-mcp/blob/main/extension/PRIVACY.md)).
- **SAP's authorisations are the limit.** Writes are on by default
  (`SAP_WRITE=on`): the agent can change what the SAP user may change, and
  the MCP client's own tool approval is the only question before a write.
  `SAP_WRITE=off` refuses every action that may write. For read-only work
  on production, use an SAP user with display authorisations only.
- **Files are written only to local folders**, named by environment
  variables (with defaults in the working directory): recordings, traces
  and their pages, exports, saved test code, downloads, debug captures,
  and the agent CLI's answers and screenshots. Each is in the table under
  [What is stored on disk](#what-is-stored-on-disk).

## What runs where

```
 User's machine                                                  │  Elsewhere
                                                                 │
 MCP client ──stdio──▶ sap-ui-automation ──▶ SAP GUI (scripting)│──▶ SAP system (as today)
     │                       │                                   │
     │                       ├──▶ Chrome / Edge (DevTools, local)│──▶ SAP system (as today)
     │                       │                                   │
     │                       └──▶ DIAG router, 127.0.0.1:3298 ───│──▶ SAP system (Windows, unless SAP_GUI_METHOD=scripting)
     │                                                           │
     └──────────── screen content, screenshots ──────────────────│──▶ model provider chosen by the user
```

The connection from SAP GUI or the browser to the SAP system is the one the
user already has. The server adds no new path to SAP, except that SAP GUI's traffic passes
through a relay on its way when a connection entry routes through it (the
network reader). The relay, the DIAG router, is a background process of the
user's own that the first server needing it starts; it outlives the servers
so that a logon through it does not drop with a chat. On Windows it listens
on `127.0.0.1:3298` unless `SAP_GUI_METHOD=scripting`; it accepts
connections from this machine only, from any user or program on it, and
relays to the next hop the route request names. On a Remote Desktop, Citrix
or SSH session it starts only with `SAP_DIAG_PORT` or `SAP_GUI_METHOD=diag`.
**Not protected against:** on a machine several people log on to,
another user's SAP Logon entry routed to `127.0.0.1:3298` reaches whichever
user's router holds the port, which reads that traffic, logon included.
Give each user their own `SAP_DIAG_PORT` and SAP Logon entry, or use
`SAP_GUI_METHOD=scripting`. Servers read through it over a local
socket in the user's private state folder (on Windows a named pipe of a
random name), with a token in a file only the user can read. That file also
says where the router listens, so no other user can take its place. The router
keeps up to 64 MB of each connection's traffic in memory, logon included,
for a server that attaches later; it writes none of it to disk.

## Data flows

| From | To | What | How | Leaves the machine? |
| --- | --- | --- | --- | --- |
| SAP GUI for Windows | server | the screen's controls, texts and values | SAP GUI scripting, through a Windows PowerShell process the server starts | no |
| Chrome or Edge | server | the content of SAP tabs (Web GUI, Fiori) | Chrome DevTools protocol on the local endpoint the browser announces, or the one named in `SAP_CHROME_CDP` | no |
| Chrome extension | server | the DevTools protocol of the tabs of registered systems only (`SAP_BROWSER=extension`) | a WebSocket to the server on `127.0.0.1` (ports 47823 to 47830), after pairing | no |
| the user's Chrome | the SAP window in a container (`SAP_CHROME_INSPECT`) | the user's logon, typed in DevTools, and the picture of the page | the DevTools protocol, through the server's relay, on a port published on `127.0.0.1` | no |
| SAP GUI | DIAG router, then SAP | SAP GUI's DIAG traffic (network reader only) | a SAProuter on `127.0.0.1` that relays to the next hop of the route | only to the SAP system or router, as before |
| DIAG router | server | a copy of that traffic, logon included, for the server to decode | a local socket or named pipe, after the router's token | no |
| server | MCP client | the screen as text, action results, screenshots | stdio | no |
| MCP client | model provider | what the client puts in the model's context | the client's own connection | **yes**, to the provider the user configured |
| server, CLI, SDK | disk | recordings, traces, exports, downloads, CLI answers, debug captures | local files (below) | no |

The server itself calls no model. Replaying a recorded test needs none.

## What is stored on disk

Every file, folder and local endpoint the server, the CLI and the SDK
write, read or open, with what it holds and when code runs from it.
Recordings, trace pages, trace screenshots and exports are never written
through a link: a new file is renamed over the old one, which replaces a
link there instead of following it. An export does not replace a file of
its name unless asked (`"replace": true` in `sap_record`, `--force` on the
command line).

Every export fills in the recorded values as defaults and names the system
and client. Replace them before you share an export as a template.

| Artifact | Where | Can contain | Who reads it | When code runs |
| --- | --- | --- | --- | --- |
| Recording `<slug>.saptest.json` | `SAP_RECORD_DIR` (default `./sap-tests`) for the MCP tools. Any path on the CLI. | Name and description. Who recorded it, and the system and client. The start screen. Variables with the recorded values. For each step: the action with its typed values, the target id and label, a risk label, the screens before and after, the status bar text, checks and capture patterns, and a note. Labels and notes are the author's text. A step's target must name the control its action acts on, or the file is refused. | `sap_replay`, `sap_record` export and code, workflow commit parity, CLI `replay`, `export` and `show-trace`, and people it is shared with. | Never on load. The MCP tools read it only as a regular file, never through a link. Replay drives SAP: first a clean start, then each step. Each step is assessed again on the live screen, and the guard ignores the file's risk label. Patterns are compiled at replay, so a slow pattern stalls the server during that replay. An export turns it into a script or a test: read the export of a recording you were sent before you run it. |
| Temp file `.<random>.tmp` | Next to a recording, a trace page, a screenshot or an export that replaces a file, for a moment on each write. | The whole file. | Nothing. It is renamed over the file. | Never. It is always a new file, so nothing is written through a link, and the rename replaces a link at the file's name instead of following it. |
| Trace `<test>.saptest.json` | Runner: `<outputDir>/<test>/` (default `./sap-results`, which `init` git-ignores). SDK: `connect({ trace })`. `sap_workflow_run`: `SAP_RECORD_DIR/sap-results/`, which it refuses when that is a link. The runner follows a linked `outputDir`, which is your own setting. File modes follow the umask. | Everything a recording holds. Also, for each step: the compact screen after it (visible field values and table rows, with password fields empty or `***`), the SDK code line and a screenshot path. | `show-trace`, the html reporter, `replay` (a trace is also a valid recording), and people. | Never. Replaying it drives SAP through the guard. |
| Step screenshots `<test>.trace/step-N.png` | Next to the trace, in a real folder: a linked `.trace` folder gets none. Only written with `screenshots: true`, which is off by default. | The SAP window after each step, with password fields masked. The DIAG fallback copies that area of the screen, so it can catch windows that lie over SAP. | Trace pages and people. | Never. |
| Trace page | `show-trace` writes `<name>.html` next to the JSON, or to `--out`, and replaces any file of that name. It refuses a link there. The html reporter writes `<trace>.saptest.html` next to each trace. | Everything in the trace, with its screenshots inlined. Only regular PNG, JPEG, GIF or WebP files inside the trace's folder are inlined, never a link. | The person who made it, and anyone they give it to. The guide suggests attaching it to a ticket. | When it is opened: only its own inline script (step keys, diff toggle), under CSP `default-src 'none'`. No trace text runs. `--open` starts the system's file opener. |
| Test reports | From the runner: `sap-results/index.html`, `junit.xml` and `results.json`. From replay: `replay --junit <file>`. | Test titles and files. Errors and stacks, which can quote SAP text and local paths. Times and trace links. `results.json` adds captured outputs. The replay JUnit file adds the compact screen at a failure. | People and CI servers. | Never. `index.html` has no script and no screenshots. |
| Replay result | The `sap_replay` answer, or CLI `--json`. | Step outcomes, variables, the screen at a failure and a proposed repaired recording. Nothing is saved. | The agent and CI. | Never. |
| Cloud ALM export `<slug>.calm.json` | `SAP_RECORD_DIR` from MCP. Next to the file, or `--out`, from the CLI. | A title and steps in words, with labels and control ids. Its Preparation section names the system and client and lists the test data with the recorded values. | A Cloud ALM MCP tool, then Cloud ALM, which the whole project shares. People. | Never. Its evidence flags come from the file's risk labels. |
| Gherkin export `<slug>.feature` | As for Cloud ALM. | Step sentences, labels and an Examples row with the recorded values. | People and Cucumber-style tools. | Only through that tool's step definitions. |
| SAP GUI script export `<slug>.vbs` | As for Cloud ALM. | Recorded values as `Var()` defaults, the system and client in the header, control ids and checks. | `cscript` and SAP GUI script playback. | When it is run, with Windows Script Host rights, outside the guard and outside `SAP_WRITE`. It attaches to the first SAP GUI connection without checking the system. |
| Playwright export `<slug>.spec.ts`, `<slug>.psap.spec.ts` | As for Cloud ALM. | Recorded values as defaults, the system and client in comments, control ids and its own logon helper. | Playwright, run with `SAP_USER` and `SAP_PASSWORD` set. | When it is loaded and run, outside the guard and outside `SAP_WRITE`. |
| SAP test export `<slug>.sap.ts`, and the `sap_record code` answer | `SAP_RECORD_DIR` (the same path as the library workflow of that name), the CLI output path, or the tool answer. | `const vars` with the recorded values. A header with the surface, system and client. The description, notes and TODO lines as comments; the TODO lines quote SAP popup titles and status texts. | `sap_library`, `sap_workflow_run`, `sap-ui-automation test` and the agent. | At import and when the test runs. An export does not replace a library workflow of the same name unless `"replace": true` is passed. |
| Workflow `<slug>.sap.ts` | `SAP_RECORD_DIR`, which is also the folder that `init` makes the test folder. | Any TypeScript, with a first-line `// @sap-workflow {…}` header that gives the description, inputs, outputs and checks. | `sap_library` (the list shows the header; inspect sends the full text to the model), `sap_workflow_save`, `sap_workflow_run`, `sap-ui-automation test` and `test --list`, and SDK `runTests()`. | On import only. `sap_workflow_run` imports it after static checks, in a worker thread of the server process, with full Node APIs and only the guard's five settings in its environment (not the server's). `test` and `test --list` import it with no checks, and so does `runTests()`. Never at save, list, inspect or type check. The checks are best effort, not a sandbox: only the SAP actions the code sends through the SDK go through the guard. |
| Run copy `.sap-code-runs/<slug>-<uuid>.ts` or `.mjs` | `SAP_RECORD_DIR`, mode 0600. | The workflow with its imports pointed at this installation, plus variable overrides. | The workflow worker. | Imported during `sap_workflow_run`, then deleted. It stays on disk if the process dies. |
| Workflow lock | MCP: `.workflows/<name>-<sha256>.sap.lock.json`. CLI and legacy: `<name>.sap.lock.json` next to the test, which is often committed. | For each step: control ids, screens, status messages, typed values, risk and repairs. Also the system, client and surface it was verified on. | The host before a run (target check) and the verifier. | Never runs code. On drift it applies up to 4 stored repair actions that are not in the reviewed source. Each one goes through the guard. |
| Verification receipt `.workflows/<name>-<sha256>.status.json` (legacy `.passed`) | `SAP_RECORD_DIR`. | The latest attempt (time, surface, `SAP_WRITE`, status) and the last pass. | `sap_library`, which shows it as written. Nothing decides on it. | Never. |
| History evidence `.workflows/<name>-<sha256>-<digest>.actions.json` | `SAP_RECORD_DIR/.workflows` (folder 0700, file 0600). Written on `sap_workflow_save` with a source. Server memory also keeps the last 200 actions of each session (`sap_history`). | The reviewed actions with typed values, screens, status texts and errors. | Nothing reads it back. People who have the folder. | Never. |
| Test config `sap.config.ts`, `.js` or `.mjs` | The nearest one at or above the working directory. | Any module code, and `use` options, `write: 'on'` included. | `sap-ui-automation test` and `test --list`. MCP runs do not load it. | Imported on every `test` and `test --list`, even when it is in a parent folder. |
| Type-check input (not a file) | Memory of the type-check worker. | The submitted code. | The TypeScript compiler. It reads only the workflow in memory, this package, the TypeScript lib files and `.d.ts` declarations in its `node_modules`; any other import fails as unresolved. | Never runs workflow code. |
| Workflow worker environment (not a file) | The worker's `process.env`, built from the guard policy alone. | `SAP_WRITE`, `SAP_ALLOW_LOGOFF`, `SAP_ALLOW_SYSTEMS`, `SAP_ALLOW_TCODES` and `SAP_BLOCK_TCODES` (not `SAP_PASSWORD`, `SAP_VAR_*` or client tokens). | Any workflow code that gets past the checks. | Not applicable. |
| Downloads | `SAP_DOWNLOAD_DIR` (default `downloads` in `SAP_RECORD_DIR` when set, else `./sap-downloads`). | Files Web GUI exports "to a local file", and browser downloads: whatever SAP exported. | People, and the agent: the action's answer names the file. | Never by the server. |
| DIAG router `127.0.0.1:3298` (`SAP_DIAG_PORT`), not a file | On Windows, unless `SAP_GUI_METHOD=scripting`. A background process of the user's own, one per port: the first MCP server, `doctor`, CLI daemon, SDK `connect()` or `test` that needs it starts it (or `diag-router start`), the others attach, and it outlives them all. On a Remote Desktop, Citrix or SSH session, servers in `auto` start it only with `SAP_DIAG_PORT` set. It exits after `SAP_DIAG_IDLE` minutes with no connection and no reader, or on `diag-router stop`. | The traffic of every SAP GUI connection routed to it. It keeps up to 64 MB of each connection's traffic in memory, logon included, for a server that attaches later, and writes none of it to disk. That traffic becomes sessions and screens for each attached server's agent. | Any local program can connect to it. On Remote Desktop or Citrix hosts, so can any other user. Servers read through its control socket (below), after its token. | On each route request it dials the host and port the request names. Its sessions decide which SAP GUI window the input host acts on. |
| DIAG capture `diag-<epoch ms>-<n>.bin` | The `SAP_DIAG_CAPTURE` folder, only when that variable is set. The DIAG router writes it; a relative path resolves against the working directory of the server that started the router. The folder gets default permissions. The file is mode 0600 on POSIX; on Windows `icacls` limits it to the user. | Every byte in both directions after the route request. That includes the logon with the user and password (compressed, so a text search finds nothing), every screen, table, grid and tree, file uploads and downloads, and other sessions on that connection. It does not hold the route request's hop passwords. On a shared host it can hold other users' traffic. | No shipped code. The dev scripts in `scripts/diag-dev/` read it, and so does anyone who can read the folder. | Never as data. Creating it on Windows runs `icacls`. |
| DIAG dev replay output | Written by `scripts/diag-dev/replay.ts` (not shipped). With no outdir it uses a temp folder (0700); a given outdir gets default permissions. | Full views, and the whole decoded model as JSON, hidden table-cell text included. | A developer. | Never. |
| Logs and doctor output | The MCP server's stderr, the CLI daemon log `<stateDir>/<key>.log` (0600), the DIAG router's log `<stateDir>/diag-<port>.log` (0600), and `doctor`. | Capture warnings and the capture path, `routed to <host>:<port>` lines, and refused routes with SAP host names. The DIAG decoding check names RFC functions and tables, with no field values. | The user, and bug reports. The issue template asks people to replace host and user names. | Never. |
| CLI daemon state `<key>.sock`, `<key>.token` | `SAP_CLI_STATE_DIR`, else a folder of the user under `XDG_RUNTIME_DIR` or the temp folder (0700), or `%LOCALAPPDATA%\sap-ui-automation\daemons` on Windows (a named pipe there). | The daemon's socket and the token a call must send. | The agent CLI and its daemon. | Never. |
| DIAG router state `diag-<port>.sock`, `.token`, `.lock` | The same folder as the CLI daemon's (on Windows a named pipe of a random name). | The router's control socket; the token a reader must send, which also says where the router listens, so no other user can take its place (0600); the start lock (0600) while one starts. | Servers, `doctor`, the CLI daemon and `diag-router`. | Never. |
| Screens in answers | Tool answers and the sessions list. | Screen content, the SAP user, system and client, and (for DIAG) the SAP host and port. The view leaves out hidden fields, but the DIAG in-memory model still holds hidden table-cell text. | The agent and its model provider. | Never. |
| SAP GUI value-list cache (read only) | `%LOCALAPPDATA%\SAP\SAP GUI\Cache\…\DataP_sapvalueset*`. | Dropdown keys and texts. | The input host, for `combo`. The list id must be 32 hex digits. | Never. |
| Agent CLI answers `.sap-gui/screens/<n>-<tag>.txt` or `.png` | `SAP_CLI_DIR` (default `./.sap-gui/screens` in the working directory), mode 0600. The last 200 are kept. With the default, the CLI first writes `.sap-gui/.gitignore` holding `*`, so git leaves the folder out; a folder named in `SAP_CLI_DIR` gets none. | The whole screen of every `look`, `act`, `okcode` and `open`, and every screenshot. | The agent, by reading the files. Anyone with the project folder. | Never. |
| `init` and `setup` | `init`: `sap.config.ts`, `sap-tests/example.sap.ts`, lines in `.gitignore` and the skills, in the working directory. `setup`: the MCP clients' configuration files, each with a `.bak` copy, and the skills in the agents' folders. | Settings, an example test and the skills. No SAP data. | MCP clients, `sap-ui-automation test` and agents. | `sap.config.ts` and the example when `test` runs; the client configuration when the client starts the server. |
| npm package | Run by `npx sap-ui-automation`. Built by the release workflow from a clean tag. | `dist/` (with the PowerShell host scripts and the bundled TypeScript compiler), `skills/`, `docs/**/*.md`, `extension/`, `native-host/host.mjs`, README, CHANGELOG and LICENSE. No tests, examples, captures or source maps. | npm, MCP clients and SDK users. | `dist/cli.js` on every start. The `.ps1` scripts on Windows, through an absolute `powershell.exe` path. `host.mjs` when Chrome starts the extension's helper. The compiler when workflows are checked. |
| Claude Desktop bundle `.mcpb` | GitHub release asset. | `dist/`, production `node_modules`, the manifest, README, LICENSE and icon. | Claude Desktop. | When Claude Desktop starts the server. |
| Claude Code plugin | `.claude-plugin/`, `.mcp.json` and `skills/` in the repository. | Plugin metadata, and an MCP entry `npx -y sap-ui-automation` with `SAP_WRITE` defaulting to `on`. | Claude Code. Also a project `.mcp.json` that loads when the repository is opened. | When the plugin starts. It runs the latest npm version, not the plugin's version. |
| Docker image `ghcr.io/didroai/sap-ui-mcp` | Built by the release workflow from a clean tag, after the npm publish is approved, for `linux/amd64` and `linux/arm64`, with provenance and an SBOM. Or by you, from the `Dockerfile`. | `dist/`, the production `node_modules` of `bun.lock`, the Chromium build of the `playwright-core` version in `bun.lock` with its Debian libraries and fonts, `tini`, README and LICENSE. No tests, docs, examples or captures (`.dockerignore`). Base images pinned by digest. | Docker, and the MCP client that runs it. | `node /app/dist/cli.js` on every start, as user `node` (uid 1000). Chromium, without its own sandbox (Docker's default seccomp profile blocks it), when the agent first needs SAP. |
| SAP window profile in a container, `/home/node/.local/share/sap-ui-automation` | The container's own file system, removed with it (`--rm`), or a named volume mounted there. | Chromium's profile: cookies (the SAP session's, while the window runs), the cache and site storage of the SAP pages, and the last SAP address (`chrome.json`). SAP's standard logon cookies are session cookies, which Chromium drops when it ends. | The container's Chromium, and whoever can read Docker volumes on the machine (root, the `docker` group). | Never. |
| Logon port `SAP_CHROME_INSPECT` (not a file) | Only when it is set. The MCP server, the CLI daemon and `browser --wait` listen there while they run: on `127.0.0.1` unless an address is named, and on another address only in a container with a network namespace of its own (not `--network host`). The Docker guide publishes it as `-p 127.0.0.1:9222:9222`. | The SAP window's DevTools protocol: full control of the window, the SAP logon included. | Anything that reaches the published port on the machine's `127.0.0.1` while the server runs: local programs, and on Docker Desktop other containers too (`host.docker.internal`). Another container on the same Docker network cannot connect to the container's port directly. With `--network host` a non-loopback address is refused. | Whoever connects can run script in the SAP pages, as with any DevTools port. |
| Agent skills `skills/*/SKILL.md` | The npm package, the plugin and the repository. `setup` copies them into agents' skill folders. | Instructions for the model: running library workflows, recording and replay, CLI use and write-mode rules. | Agent models, on matching tasks. | Never by themselves. They lead the agent to `sap_workflow_run` and to the CLI, which writes answer files. |
| Documentation `docs/**/*.md` | The npm package and the docs site. | Config and code snippets with placeholder hosts and demo system ids. | People, and agents that read `node_modules`. | The `.md` files never. The site config runs only at docs build. |
| Examples and images `examples/`, `assets/` | Repository only. | Synthetic content: a recorded test with navigate steps only, SDK scripts, prompts, client configs, the side-panel image and charts. | People, and the agents they paste prompts into. | SDK scripts run when a person runs them. Prompts shape what an agent does. |
| Test fixtures and fakes `test/fixtures/`, `test/sapgui/` | Repository only. | DIAG frames cut from a capture of SAP's public CAL/IDES trial system. They hold no logon, but they decode to the lab's host, user, client, internal addresses and workstation name. Also text views from SAP demo systems and a made-up SAP GUI world. | `bun test`, and anyone who clones the repository. | During test runs. The COM, PowerShell and `.mjs` fakes run on Windows test runs. `make.py` runs when the fixtures are regenerated. |

`./` is relative to the working directory. The MCP client chooses it when it
starts the server. The `sap_screenshot` tool returns its image to the client;
the agent CLI's `screenshot` saves it in `SAP_CLI_DIR`. Review traces, trace
pages and exports before sharing them. Leave `SAP_DIAG_CAPTURE` unset
outside debugging.

## What the agent can do

The agent acts as the SAP user whose session it works in. SAP's
authorisations are the real limit. On top of them, the server classifies
every action before it runs as **read** (value help, expanding a tree,
scrolling), **navigate** (typing, Enter, tabs, Back, Execute F8) or
**commit** (anything that may save, and anything not known to be safe).

| `SAP_WRITE` | Read and navigate | Commit (Save, Post, Delete, Release, Yes on a save popup, unknown buttons) |
| --- | --- | --- |
| `on` (default) | allowed | allowed, after the MCP client's own tool approval where it asks |
| `off` (read-only) | allowed | refused |

Under every setting:

- the system and client must be in `SAP_ALLOW_SYSTEMS`, when set;
- the transaction must pass `SAP_ALLOW_TCODES` and `SAP_BLOCK_TCODES`;
- browser tabs must be of an origin in `SAP_ALLOW_ORIGINS`, when set;
- the command field is used only through the `okcode` action;
- logging off is refused unless `SAP_ALLOW_LOGOFF=on`;
- password fields and logon screens are refused.

With `SAP_WRITE=off` the agent can still **read** everything the SAP user
can display, and can start reports with Execute (F8). Some reports update
the database when executed: block them with `SAP_BLOCK_TCODES`.

With `SAP_CODE_TOOLS=on` (off by default) the agent can also **save and
run test code** on the user's machine: `sap_workflow_save` writes a `*.sap.ts`
file to `SAP_RECORD_DIR`, and `sap_workflow_run` runs it with the user's
rights. The code is checked before it is saved and before it runs
(imports, forbidden words such as `process` and `fetch`, no write the
recording of the same name does not have). These checks are best effort,
not a sandbox: the code runs in the server's own process, and only the SAP
actions it sends through the SDK go through the guard, under the server's
`SAP_WRITE` and transaction lists. Text on an SAP screen can try to steer
what the agent writes.
Turn it on only where you would let the agent's author run scripts on that
machine. See [Reusable workflows](https://docs.didro.ai/sap-ui-automation/guides/workflows).

With `on`, the server adds no question of its own: the MCP client's
approval of each `sap_act` call is the only one, and it covers every call,
not only the ones that write. A client set to approve everything (Codex
Full Access, an allow rule in Claude Code) asks nothing
([Approval in the client](https://docs.didro.ai/sap-ui-automation/concepts/safety#approval-in-the-client)).
`off` is a safety net for agent mistakes, not a security boundary: the SAP
user's authorisations and the system the agent works in are.

**The agent CLI and a shell.** The agent CLI follows the same
`SAP_WRITE`: with `on` it writes, and your approval of each command is the
only question before a write. The settings are environment variables. An
agent that can run shell commands (Bash in Claude Code, Codex, Cursor) can
put `SAP_WRITE=on` in front of a command and undo your `off`.
The CLI cannot tell who set it. The bundled skills tell the agent never to
set `SAP_*` itself, but only your approval of each command actually stops
it: do not auto-approve `sap-ui-automation` commands, or shell commands in general,
when the agent works on a system where writes matter. The same applies to
an agent that can edit its MCP client's configuration.

**Not tried on a live system yet:** writes through the network reader,
which have run on test systems only
([Network reader](https://docs.didro.ai/sap-ui-automation/guides/network-reader#limits)).

More in the [safety model](https://docs.didro.ai/sap-ui-automation/concepts/safety) and the
[configuration reference](https://docs.didro.ai/sap-ui-automation/reference/configuration).

## Recommended settings for production systems

Start with a test or sandbox system. For a production system:

- **A dedicated SAP user with display authorisations only.** The server
  cannot exceed what the user may do; this is the control that holds when
  everything else fails.
- **`SAP_WRITE=off`** (read-only; the default is `on`), as a safety net
  for agent mistakes on top of the display-only user. Leave writes on only
  on systems where a wrong save can be reversed.
- **`SAP_ALLOW_SYSTEMS=PRD/100`**: name the systems and clients the agent
  may see. Sessions on others are hidden.
- **`SAP_ALLOW_TCODES`** with the transactions the task needs, or at least
  **`SAP_BLOCK_TCODES`** with the ones it must never open: `SE38`, `SA38`,
  `SE16N`, `SM30`, `SE37`, `SM59`, `SU01`, `PFCG`, and your own reports that
  update data on F8.
- **`SAP_ALLOW_ORIGINS`** with the SAP hosts, for Web GUI and Fiori.
- **A separate Chrome profile** for SAP work, so that remote debugging
  does not expose other tabs.
- **A model provider with zero data retention**, or a self-hosted model,
  under a data processing agreement that covers SAP data. Screen content
  reaches the provider; this is where personal data in SAP leaves the
  machine.
- **No other MCP servers that can send data out** (web, email, chat) in
  the same client session, if the data must not leave through them.
- **Leave `SAP_DIAG_CAPTURE` unset**, and keep
  `SAP_RECORD` off unless a test is being recorded.
- **Leave `SAP_CODE_TOOLS` off**: it lets the agent run code on the machine.
- **Pin the package version** in the client configuration
  (`sap-ui-automation@0.6.0`), so that the code that runs is the code you
  reviewed.

Example, for a read-only investigation:

```sh
SAP_WRITE=off
SAP_ALLOW_SYSTEMS=PRD/100
SAP_ALLOW_TCODES=VA03,MM03,ME23N,FB03,XD03
SAP_ALLOW_ORIGINS=https://sap.example.com
```

## Threat model, in summary

**Assets:** SAP data on screen; the user's SAP session and authorisations;
recordings, downloads and captures on disk.

**Actors:** the model or agent, mistaken or prompt-injected through text on
an SAP screen; other programs on the same machine, which can reach the
browser's DevTools endpoint, the logon port of `SAP_CHROME_INSPECT` and the
network reader's local port; anyone who gets a recording or a capture.

**Mitigations:** every action rated before it runs, failing closed, and
writes refused with `SAP_WRITE=off`; the client's own approval of each
`sap_act` call; allow lists of
systems, transactions and browser origins on every call; the command field
only through `okcode`; no logon, no passwords; a write runs only on the screen the
agent was last shown; the network reader bound to `127.0.0.1`; the logon
port of `SAP_CHROME_INSPECT` on `127.0.0.1` outside a container and with
`--network host`, and inside a container with a network of its own closed to
direct connections from the same Docker network; DIAG
captures readable by their owner only; recordings confined to one folder;
recordings, trace pages and exports never written through a link.

**Not protected against:** an agent that passes what it read to another
tool it has; an agent with a shell that sets `SAP_WRITE=on` for the agent
CLI itself, where you approve commands without reading them; a custom
button whose text looks safe but writes; reports that
write on F8; other local programs using the DevTools endpoint; anything the
SAP user's authorisations allow once writes are on. The guard is a safety
net for an agent that makes mistakes, not a security boundary.

The full threat model is in
[SECURITY.md](https://github.com/DidroAI/sap-ui-mcp/blob/main/SECURITY.md).
