Uploads, approvals and signatures
A function is code that runs on your LEA server with access to secrets. This guide explains who may add or change functions, how to confirm your identity, how to make a second administrator approve every upload, how to accept only signed code, and what a function can and cannot do.
Before you start
- You need the admin role. Other roles can look at functions but not change them.
- For approvals you need a second administrator account (a different person).
- For signatures you need
openssland theleacommand line on the computer where code is signed.
Who may change functions
Every change to functions (upload, approve, reject, delete, set or delete a secret, change the policy) needs one of:
| Credential | Condition |
|---|---|
| Your console session | You confirmed your identity within the last 10 minutes (see the next section) |
| A personal access token | An administrator's token with the Manage functions permission. For the lea command line and CI pipelines |
Refused: tokens without Manage functions, the normal lea login sign-in token, and the server's internal host
tokens. Looking at functions, reports and test runs needs only the admin role.
Attaching a function to a rule is a normal rule change: any administrator can do it in the rule editor.
Confirm it is you (step-up)
When you upload, approve, delete, change a secret or change the policy, and you have not confirmed your identity in the last 10 minutes, a dialog titled Confirm it is you opens:
- Local account (password): type your Password and click Confirm. The action then continues. Wrong passwords count towards locking your account.
- Single sign-on: click Re-authenticate. Your identity provider asks you to sign in again, even if you are already signed in there. You return to the same page. Repeat the action: the console does not repeat it for you. Identity providers that cannot prove a fresh sign-in, such as Google, do not offer this; use a passkey.
- Passkey: click Use passkey and confirm with Touch ID, Windows Hello, your phone or a security key. The action then continues. Add passkeys in My account → Passkeys; see Passkeys.
After that, other function changes in the same browser session do not ask again for 10 minutes.
If the identity provider signs you in as somebody else, the console shows "You signed in as a different identity. Re-authenticate as the same person."
Create a token for the command line or CI
The lea command line and CI pipelines cannot answer the Confirm it is you dialog. They use a personal access token
with the Manage functions permission instead.
- Open Settings → AI Assistant.
- Scroll to Personal access tokens and click Create Token.
- In Name, type what the token is for, for example
functions-ci. - In Expires, choose 30 days, 90 days, 180 days or 1 year. Shorter is safer.
- Tick Manage functions: upload, approve, delete, secrets and policy. You do not need Allow write tools.
- Click Create. Confirm it is you if asked.
- The token is shown once ("This token is shown only once. Copy it now."). Click the copy icon next to Token and store it in a safe place, for example your CI system's secret store or a file only you can read.
You should see: the token in the list with the chips Manage functions, Role: admin and its expiry date.
Use it:
LEA_TOKEN="$(cat ~/lea-functions.token)" lea functions push ./open_ticket
or store it once in the command line's profile with lea login --token - < ~/lea-functions.token.
The token acts as you: if your account is disabled or no longer an administrator, the token stops working. You must also keep signing in to the console (a token of somebody who has not signed in for 90 days stops working). Revoke a token with the bin icon on its card.
Upload a function
A function can be uploaded as a folder or an archive. All forms give the same result (the same content digest):
| Form | How |
|---|---|
| A folder | Upload → Choose folder |
A .tgz archive | Upload → Choose .tgz or .zip |
A .zip archive | Upload → Choose .tgz or .zip, or New function → Upload now |
| From a terminal | lea functions push DIR (folder, .tgz or .zip) |
Steps in the console:
- Open Settings → Functions and click Upload (or New version on an existing function's card).
- Choose the folder or archive. Check Function name: it must equal the
nameinfunction.json. - Optional: Add signature (.sig) (see Require signed uploads).
- Click Validate. Nothing is stored yet.
- Read the report (next section), then click Upload and activate (or Upload for approval).
Important: Browsers cannot read file permissions. With Choose folder, every file is stored as not executable. Start scripts through their interpreter in
function.json:["sh", "main.sh"], not["./main.sh"]. Archives and theleacommand line keep the permissions.
If the folder has no function.json, the report offers Create function.json, which opens the wizard to write one.
Read the validation report
The report tells you exactly what you are about to run on the server:
- Pills: the signature (SIGNED with key fingerprint, UNSIGNED, BAD SIGNATURE), NEW FUNCTION or SAME AS ACTIVE, NEEDS APPROVAL, and AI KEY when the function receives the AI provider's API key.
- Entrypoint, Timeout, Arguments, Secrets it will receive, Environment passed.
- A warning when an environment name in
envis not allowed on this server and will not be passed. - Content digest: a fingerprint of all files, names and permissions. It is the same whatever the archive format.
- Size and the number of files.
- For a new version: Changes against the active version, with
+added,−removed and~changed files, and line-by-line differences for text files. Read them before you approve or upload. - Errors in a red box. The upload button stays disabled until they are fixed.
The file table (click Show N files for a new version of an existing function) lists every file with its Path, Size, Mode and SHA-256:
| Column | What it shows |
|---|---|
| Mode | The file's Unix permissions: 0755 means the file may be started as a program, 0644 means it may not. |
| SHA-256 | A fingerprint of the file's content, of which the first 12 characters are shown. Any change to the file changes it. |
Require a second administrator's approval
With approval on, an upload does not become active by itself. It waits until another administrator approves it. The version already active keeps running for rules in the meantime.
Turn it on
- In Settings → Functions, click Policy.
- Under Review, switch on Require approval by a second administrator.
- Click Save and confirm it is you.
You should see the pill APPROVAL REQUIRED at the top of the page.
Upload for approval (first administrator)
- Upload as usual. The report shows NEEDS APPROVAL, and the button says Upload for approval.
- Click it. You should see "is staged as upload #N and waits for another administrator to approve it".
- The function's card shows UPLOAD #N PENDING. Tell the second administrator the upload number.
You can already Test run a staged upload, but it runs without secrets and without the AI key until it is approved. If you upload again before a decision, the newer upload replaces the older one (the older one is marked superseded).
Approve or reject (second administrator)
- Open the Function upload awaiting approval notification, or Settings → Functions and the table Waiting for approval, and click Review.
- Read the report and especially Changes against the active version.
- Optional: click Test run to run it on a real result (without secrets).
- Type a reason in Note (kept with the decision).
- Click Approve and activate or Reject. Confirm it is you.
The uploader cannot decide on their own upload, even with a token: the buttons are disabled with the hint "You uploaded this version; another administrator must decide." On approval, LEA Platform checks the stored code again against its fingerprint and the signature policy before activating it.
| Column or button | What it means |
|---|---|
| Upload | The number LEA Platform gave this upload, used to review, approve or reject it. |
| Status | Where the upload stands in review, for example PENDING while it waits for a second administrator. The table Waiting for approval only lists pending uploads. |
| Digest | The first 12 characters of the content digest, a fingerprint of all files, names and permissions. Compare it with the digest the uploader gives you. |
| Signature | Whether the code is signed with a key you trust: SIGNED with the key fingerprint, UNSIGNED or BAD SIGNATURE. |
| Test run | Runs this uploaded version in the sandbox on a real host result, without sending anything to the host. A pending upload runs without secrets. |
| Approve and activate | Makes this upload the version that every rule runs, after LEA Platform checks the stored code and signature again. Only another administrator can do it. |
From a terminal: lea functions uploads --pending, then lea functions approve 12 --note "reviewed" or
lea functions reject 12 --note "why". lea functions push DIR --wait waits until the upload is decided.
Require signed uploads
With signatures required, LEA Platform only accepts code signed with a key you trust. The signature covers the content
digest, so it does not matter whether you upload a folder, .tgz or .zip, but any change to any file needs a new
signature.
Create a signing key
On the computer (or build server) that signs releases, not on the LEA server:
openssl genpkey -algorithm ed25519 -out signing.pem
openssl pkey -in signing.pem -pubout
The first command creates the private key signing.pem. Keep it secret. The second prints the public key, which starts
with -----BEGIN PUBLIC KEY-----. Copy it.
Trust the key in LEA Platform
- In Settings → Functions, click Policy.
- Under Trusted signing keys, type a New key name (for example
release-signing-2026) and paste the public key into Public key. - Switch on Require a signature from a trusted key.
- Click Save and confirm it is you.
You should see the pill SIGNATURE REQUIRED · 1 KEYS. You cannot require signatures without at least one key. Up to 32 keys can be trusted. To retire a key, click its bin icon and Save.
Sign and upload
lea functions sign ./open_ticket --key signing.pem --out open_ticket.sig
lea functions push ./open_ticket --sig open_ticket.sig
In the console: Upload → choose the folder or archive → Add signature (.sig) → choose open_ticket.sig →
Validate. The report shows SIGNED with the key fingerprint.
Refused uploads: no signature when one is required, a key that is not trusted, or a signature over different content (the code changed after signing). A signature that does not verify is refused even when signatures are optional.
Note: File permissions are part of the digest. If you sign a folder that contains executable files and then upload that folder with Choose folder, the browser drops the permissions and the signature no longer matches. Upload the archive or use
lea functions pushinstead.
Secrets
- Each function declares the names of its secrets in
function.json. Only declared names can be set, and only they are passed to the function, as environment variables. - Values are encrypted when you save them, with a key only the function runner holds. Nobody can read them back, in the console or through the API. You can only replace or delete them.
- Values appear in standard error only as
***. Functions must never put them in their answer: every console user can read answers, and hosts may receive them. - Deleting a function deletes its secrets. A later upload under the same name starts without them.
- A secret marked RE-ENTER was encrypted with a key that no longer exists. Set it again.
- A staged upload that is not yet approved runs its test runs without secrets.
- From a terminal:
lea functions secrets set NAME SECRETreads the value from the keyboard (hidden) or standard input, never from the command line.lea functions secrets ls NAMElists names only.
The sandbox
Functions run on the LEA server, isolated from LEA Platform itself:
- Under their own unprivileged user, with no extra privileges.
- A separate executor container has no LEA Platform configuration, server code, license or key files. Before accepting work, it checks isolation as the function's user. Visible protected paths, resolvable internal service names or an unavailable executor disable execution and show the reason under Runtime. Queued work waits; recovery is automatic when the executor is ready.
- Only the environment variables listed in their
function.json(secrets and allowed names), nothing else from the server. - An empty temporary folder of their own, deleted after the run.
- At most 64 processes and 64 MB per written file. After the timeout, the function and every process it started are stopped.
- Functions see the network like a LAN host. Private APIs and private proxies keep working. LEA's internal Docker services are on a separate network. Cloud metadata blocking is attempted inside the executor; unsupported hosts show a warning and still run functions. Declared and allowed proxy variables still pass through unchanged. Proxies must enforce their own destination policy.
- Host-published ports remain reachable and require their own authentication. Ask your operator to apply the
host firewall advisory to the function bridge only (
lea-fn0by default). It also blocks the host's own services and published database ports. Never apply a blanket Docker metadata block: SES email and S3 backups can need the instance role. Installation prints a reminder and does not change rules. - On EC2, require IMDSv2. Hop limit 1 is an extra defense when email/backups use explicit access keys; containers that use the instance role generally need hop limit 2. Your operator must choose based on those features.
What a function can reach
Functions can contact the internet, your LAN/private services and proxies, and ports published on the LEA host unless you apply the optional host rules.
They cannot contact LEA's internal database, API or PostgREST by service name or through their internal Docker network. They cannot read server files, settings, keys or other services' credentials. A function receives its own declared secrets and, when explicitly configured, the AI settings. A published LEA port is still reachable and requires authentication. A proxy can relay traffic to destinations it can reach, so configure its own destination policy.
Cloud metadata is blocked inside the executor when the host supports it. If installing or checking the block fails, Runtime displays WARNING: metadata block inactive: …. Functions keep running; installation is never blocked by this warning. The executor bridge uses IPv4 only; any IPv6 metadata check is advisory.
The optional host firewall rules apply only to lea-fn0 (or your configured replacement). IPv4 rules suffice for the shipped bridge; apply IPv6 rules only if you add IPv6 yourself. Installation prints information only and never changes your firewall. Never block metadata for all Docker networks: SES email and S3 backups may need instance-role credentials.
Turn functions off
Enable functions controls execution across the installation and is on by default.
- Open Settings → Functions and click Policy.
- Under Execution, switch off Enable functions.
- Click Save and confirm it is you.
You should see Functions disabled by an administrator under Runtime. The supervisor claims no jobs, rule hooks are not queued, and test runs and new executions are refused. Uploads, secrets and configuration remain viewable and editable with their existing permissions. Runs already executing may finish; queued jobs wait. Turn the switch on and save to resume queued work. The change is audited and needs the same identity confirmation or Manage functions token as other policy changes.
What a function can make hosts do
- Nothing, with Record only.
- Run the rule's own remediation, with Run the remediation with the output.
- Run one of the rule's own actions, with Let the function pick an action.
A function never sends commands. It sends data: files placed in the working folder of the command, and its answer as
lea_artifact.json. The commands themselves are in the rule definition, where administrators review them, and where
versions and rollout apply to them. So the person who controls what hosts run is whoever edits rules, not whoever
uploads functions.
Hosts check the files before they use them. Files are written to the LEA agent's temporary folder. Agents of the current release create them without following symbolic links; on hosts shared by several users, keep agents up to date.
The audit trail
Open Audit. Every function change is recorded with who did it, how (console or token) and the content digest:
- uploads, staged uploads, approvals and rejections (with the note), deletions;
- test runs (which host and rule);
- secrets set or deleted (names only, never values);
- policy changes and signing keys added or removed;
- changes to a rule's function hooks (as rule changes).
If something goes wrong
- The Confirm it is you dialog appears again and again, or the command line gets
step_up_requiredorfunctions_scope_required: see When a function does not work. - An upload is refused: the report or the error message names the reason. See When a function does not work.
Related
- What functions are
- Writing function code
- Functions reference: security model
- Sign-in reference: step-up
- CLI reference