Security
On this page
- Defaults
- Access rules
- Behind a proxy
- Two collection rules
- Console protection
- Roles
- Where the console passwords come from
- Brute force and the audit log
- What the page loads
- Host names and DNS rebinding
- HTTPS
- Buttons in the bar
- Audit log
- Heap dumps
- AI data flow
- Lensy threat model
- MCP servers
- Channels
- The Secret Store
- The diagnostic bundle
- Redaction
- Size caps
- Safe output
- Security notes on your own pages
- Checklist
Security
Lens exposes SQL, scopes, headers and stack traces. Keep the bar for development and test machines. If you turn the console on for a server that real users reach, follow Running Lens in production.
For the operator's view, read Hardening and threat model (what the console can and cannot do, what leaves the server) and the Production checklist. This page is the reference.
Data and AI
Defaults
- Everything is off.
bar.enabledandconsole.enabledare bothfalse. - The bar and the console each have their own access rule. Both default to
"local", which means loopback only (127.0.0.1,::1). - The console also needs a password. Without one nobody can sign in: an allowed caller sees the "Set a password first" page, and every other route answers 503 (the sign in, the registration, the API and the live stream). The password comes from
boxlang.jsonor from the Secret Store, see Where the console passwords come from. - Heap dumps (
console.allowHeapDump, BoxLang+ only) and AI calls to a model (ai.enabled) are off. See Heap dumps and AI data flow. The disk store writes only with BoxLang+ or a trial, see Licensing. - A caller that is not allowed gets nothing. The bar is not injected, and the console answers a plain 404, so it does not reveal that it exists.
Access rules
| Setting | Default | Meaning |
|---|---|---|
bar.access | "local" | "local", "all", or a list of exact IPs, CIDR ranges and the words local and private. |
bar.allowAllIPs | false | Must be true for bar.access: "all". Otherwise Lens falls back to loopback and logs an error. |
console.access | "local" | Same format as bar.access. "all" is accepted and logs a warning. |
access.allowedHosts | [] | Restrict to these Host header names. Empty means any host. Applies to both surfaces. |
access.requireHeader | "" | Require a request header: "Name" or "Name=value". Applies to both surfaces. |
private means loopback plus 10/8, 172.16/12, 192.168/16, fc00::/7 and link-local. Only literal IP addresses are matched, Lens never does a DNS lookup.
{
"modules": {
"bxLens": {
"settings": {
"bar": { "enabled": true, "access": [ "local", "10.8.0.0/24" ] },
"console": { "enabled": true, "password": "bxsecret:..." },
"access": { "requireHeader": "X-Dev=1" }
}
}
}
}
Behind a proxy or load balancer, see Behind a proxy.
Behind a proxy
With a proxy or load balancer in front, the direct connection comes from the proxy, not from the user. Lens can take the client address from a header so console.access, bar.access and the login lockout use the real address.
| Setting | Default | Meaning |
|---|---|---|
access.trustProxyHeader | true | Use the header at all. |
access.proxyHeader | "X-Forwarded-For" | The header to read. |
access.proxyPeers | "private" | Which direct connections may set the header: private, local, or a list of IPs and CIDR ranges. |
The rules:
- The header is believed only when the direct connection comes from one of
proxyPeers. From any other address the header is ignored, so a user cannot pick an address by sending the header. - With a list of addresses in the header, Lens reads it from the right and uses the first address that is not a trusted proxy.
- A header can never turn a remote peer into a loopback caller. If the header names
127.0.0.1and the peer is not loopback, Lens keeps the peer address. - The
X-Forwarded-Protoheader is believed under the same rule, when Lens decides whether a request is HTTPS.
The default private trusts any proxy on a private network. If other machines on that network can reach the runtime directly, list your proxy addresses in access.proxyPeers. If no proxy is in front, set access.trustProxyHeader to false.
Two collection rules
- The bar collects only for callers allowed by
bar.access. A caller who is not allowed is not tracked. - The console collects every request on the server once it is enabled, because it shows production traffic. Only allowed, signed-in people see the data. Pair this with
collect.level: "light". See Running Lens in production.
Console protection
The console is a single page with these protections.
| Protection | Detail |
|---|---|
| Passwords | Set in the console (a salted slow hash in the Secret Store, wins) or in boxlang.json: console.password and optionally console.viewerPassword as an environment variable placeholder (${env.NAME}) or a bxsecret: value. BoxLang decrypts a bxsecret: value with the runtime seed at load time. See Where the console passwords come from and Set passwords: plain, env or bxsecret. The settings page shows only set or not set. |
| Sessions | Kept in one place, console.sessionStorage, and nowhere else: this server's memory by default (a restart signs everyone out), or with BoxLang+ a BoxLang cache or the store folder (hashes only), so several servers share them and a sign out ends the session on every server, see Sign ins across servers. When the cache cannot be read, nobody can sign in until it can. The cookie is bxlens_session: HttpOnly, SameSite=Strict, and Secure on HTTPS. The store volume, and the cache, must never be reachable by anyone but the BxLens servers. Set the same BXLENS_SECRETS_KEY on every server so the shared hashes are keyed: without it, whoever can write into the store or the cache can add a session. |
| Timeouts | Idle timeout console.sessionMinutes (30), and a fixed 12 hour maximum. |
| Lockout | After console.maxLoginAttempts (5) wrong passwords, the address is locked for console.lockoutMinutes (5). Failures are counted in a 10 minute window. Behind a proxy, the failures are also counted for the connection of the proxy itself (four times the limit, because many people share it), so a caller who sends a new X-Forwarded-For with every guess still runs into a lockout. The failures are counted by each server on its own: with several servers behind one address, rate limit POST /~bxlens/index.bxm/login at the edge, for example with a Cloudflare rate limiting rule. |
| Login header | A login must send X-Lens-Login: 1, so a form on another site cannot sign you in. |
| CSRF token | Every state change (POST) must send the session's X-Lens-CSRF token. It is derived from the session id with a one way hash, so it is never stored. |
| Restrictive CSP | Pages send default-src 'none' with 'self' for scripts, styles, connections and fonts, 'self' and data: for images, base-uri 'none', form-action 'self' and frame-ancestors 'none'. It is not fully strict: script-src has 'unsafe-eval' (the vendored Alpine.js build evaluates expressions) and style-src has 'unsafe-inline' (the console uses inline style attributes). No script from another origin and no inline script can run, but a CSP does not stop an attack that reaches Alpine expressions. A move to the Alpine CSP build and to classes instead of inline styles is planned. Responses also send X-Frame-Options: DENY, X-Content-Type-Options: nosniff, Referrer-Policy: no-referrer and Cache-Control: no-store. |
| No outside requests | Alpine.js and the Phosphor icons are vendored, fonts are system fonts. The console runs on an air gapped network. |
| Fixed assets | Only console.css, console.js, alpine.min.js and glossary.json are served as console assets. The bar's own files are served by name and hash, see What the page loads. |
| Not tracked | Console requests never appear in Requests. |
| HTTPS | console.requireHttps refuses plain HTTP, see HTTPS. |
| Roles | Admin and viewer, see Roles. |
| Audit log | Logins and changes are written to bxlens-audit.log, see Audit log. |
Set console.actions to false to turn off the actions on the server (tasks, caches, applications, watchers, the Mail queue and the approved actions of Lensy), and console.readOnly to true to refuse every change from the console.
console.readOnly refuses every change for both roles, passwords and secrets included. The routes it lets through are listed by name in the code, not by prefix: heap dumps (own switch, BoxLang+), the connection test of one datasource, the AI calls (ai/test, ai/explain, ai/ask) and the chat with Lensy (agent/chat, agent/reset, agent/approve). Changing the AI settings or the MCP servers is refused by their own check. See Console settings.
Roles
The password decides the role. The admin password gives the admin role. The viewer password (optional, ignored when no admin password is set, and a BoxLang+ feature) gives the viewer role. Both come from the console or from boxlang.json.
A viewer can:
- See Overview, Requests, Queries, Errors, Reports, HTTP, Executors, Tasks, Datasources, Applications, Watchers, Caches (statistics and key names), Modules, ORM, AI observability, Mail (without message text), Configuration, the server selector and Settings (values).
- See In flight (BoxLang+).
- Chat with Lensy (BoxLang+), with the tools a viewer may use.
- Copy a prompt.
A viewer cannot:
- Read the Logs, Environment, System, JVM, Web server and Threads pages and thread stacks.
- Open Settings, Notifications, Settings, Storage, Settings, Security, the Mail queue, the Mail settings, and the Assistant page with its settings and MCP servers.
- See the values of
console.access,access.proxyPeers,console.overridesFileandsecrets.dir, and the path of the overrides file, in Settings. - Change settings, passwords and secrets.
- Run task, cache, application, watcher and Mail queue actions, change integration switches or save the bar layout.
- Reset Queries, Errors and Reports, or Run GC.
- Test a datasource connection.
- Explain with AI or ask the questions of Ask Lens (they call the model).
- Approve an action that Lensy proposes.
- Download a thread dump.
- Download a heap dump, a log file or the diagnostic bundle (BoxLang+ or a trial).
- Read a cache value (BoxLang+ or a trial).
An admin can do everything a viewer can, and also:
- Read the Logs, Environment, System, JVM, Web server and Threads pages and thread stacks.
- Open Settings, Notifications, Settings, Storage, Settings, Security, the Mail queue, the Mail settings, and the Assistant page with its settings and MCP servers.
- See the values of
console.access,access.proxyPeers,console.overridesFileandsecrets.dir, and the path of the overrides file, in Settings. - Change settings, passwords and secrets.
- Run task, cache, application, watcher and Mail queue actions, change integration switches and save the bar layout.
- Reset Queries, Errors and Reports, and Run GC.
- Test a datasource connection.
- Explain with AI and ask the questions of Ask Lens (they call the model).
- Chat with Lensy and approve an action that Lensy proposes.
- Download a thread dump.
- Download a heap dump, a log file or the diagnostic bundle (BoxLang+ or a trial).
- Read a cache value (BoxLang+ or a trial).
A viewer who sends such a request gets a 403, and the attempt goes to the audit log as denied. Admin only, even for a read, are the routes threads, heapdump, logfiles, bundle, cachevalue, environment, system, jvm, webserver, store, ai/config, ai/mcp, mail/queue, mail/settings, notifications and security (ADMIN_ONLY in ConsoleRouter). Every request that changes state is admin only, except the chat with Lensy (agent/chat, agent/reset).
A viewer reads request data, queries, scope snapshots and key names of caches. Logs, thread stacks, the environment and system details are for admins. Request data can still be sensitive, so treat the viewer password as sensitive.
Where the console passwords come from
Each password has one source, chosen in this order:
- Set in the console. An admin sets it with
POST security/password(the Security page of Settings). It is kept in the Secret Store as a salted slow hash, namespaceauth, namesadminandviewer. This wins. boxlang.json.console.passwordandconsole.viewerPassword: abxsecret:value,${env.NAME}or plain text.- Nothing. The console shows the "Set a password first" page and refuses every other route. A password set in the console counts as configured, so a server can start with no password in
boxlang.jsononce one was set in the console.
Reset to boxlang.json removes the entry of the Secret Store (POST security/password/reset, audit password.reset), so boxlang.json is in charge again. The admin reset is refused when boxlang.json has no console.password, because the console would be left with none.
Removing the viewer login (POST security/password/remove, audit password.remove) deletes the entry of the Secret Store. Where boxlang.json holds a viewer password, the entry holds the marker disabled instead, so the boxlang.json viewer password stops working without editing the file. A reset brings it back.
Brute force and the audit log
Failed logins are counted per client in two windows, one for each role. A wrong password counts against both, because it may have been a guess at either. A sign in as a viewer clears only the viewer window, so the viewer password can never be used to give the admin window its attempts back. IPv6 clients are counted by their /64 network. Sessions (200) and failure records (5000) are capped and pruned on every login. A live stream does not keep a session from going idle.
Every field in an audit line is stripped of control characters and cut to a length, so a client cannot forge a line. Refusals are audited too: denied (viewer), denied.csrf, denied.readonly, denied.plus, denied.actions (also for a task action), denied.task (a task route or action that does not exist) and denied.access (a caller the console answers with 404, at most one line a minute per address). Audit lines are written at once, on the thread that causes them, so a full work queue never drops one. Reading a log file (logfile.read) and the environment (environment.read) are audited. A search term is logged as its length only.
What the page loads
The bar adds a small block to your page and loads five static files from /~bxlens/index.bxm/assets/ on your own server. The files hold no request data and no secret, so they are served without the console check; the data of a request is only in the page, for callers bar.access allows. The bar needs a Content-Security-Policy with (script-src 'self' 'unsafe-eval', style-src 'self', connect-src 'self'; no unsafe-inline).
Host names and DNS rebinding
A guard whose rule is exactly local accepts only the Host names localhost, 127.0.0.1 and [::1], unless access.allowedHosts is set. Add your own name there to reach the bar or console under it.
HTTPS
The password and everything on screen travel over the connection, so use HTTPS.
console.requireHttps: trueanswers a plain HTTP request with a 403. Loopback callers are exempt, so a local tunnel still works.- With the option off, the console shows a warning banner on every page when a non-loopback caller uses plain HTTP.
- The session cookie is marked Secure when the request is HTTPS.
- Behind a proxy that ends TLS, the proxy must send
X-Forwarded-Proto: httpsfrom a trusted peer, or the runtime must see the request as secure. See Behind a proxy.
Buttons in the bar
Two buttons of the bar change something: Clear event cache and Clear view cache, and Reinit framework, on a ColdBox request. They are free, and they follow the bar rules:
- Only callers
bar.accessallows can use them. The page carries a token for the caller's address that expires after two hours and when the server restarts. A request without it, with a token for another address, or from another site (Sec-Fetch-Site) is refused and written to the audit log. - They never work when
console.readOnlyis on, andbar.actions: falseturns them off. - Reinit does not send the reinit password to BxLens. BxLens only learns whether the application needs one. The password goes from the browser to the application in a form field.
- Every use is audited (
coldbox.cache.clear,coldbox.reinit).
The bar records the names of the rc and prc keys of a ColdBox request. It never records their values and there is no setting to.
Audit log
Lens writes a line for every login, failed login, lockout, logout, denied attempt and change to its own log, bxlens-audit.log, through the BoxLang logging service. It is in the BoxLang logs directory, so you can read it on the Logs page. A line looks like this:
event=settings.change role=admin ip=10.0.0.12 server=9d596ef0 keys={thresholds.slowQueryMs=50}
server is the id of the Lens instance that wrote the line, so the audit logs of many servers can be read together. See server.
The events are:
The groups are for reading: the list is in the code (Audit.log calls) and a new feature may add an event. The security alert counts login.fail, login.locked and the settings events, see the alert runbook.
Passwords and keys are never written. A line is cut at 500 characters and line breaks are removed. Lens keeps no other record and does not rotate or trim the file itself.
Heap dumps
Heap dumps need BoxLang+ or a trial. On Free the server answers 403.
A heap dump is a copy of everything in the JVM's memory: passwords, session data, keys, personal data. Lens cannot redact it.
- It is off. Set
console.allowHeapDumptotrueinboxlang.jsonto turn it on, and turn it off again when you are done. - Only admins can take and download one. A confirmation is required, and
console.readOnlydoes not block it. - The file is written to a private folder in the temporary directory, one at a time, after a disk space check. It is deleted 5 minutes after the download, or 10 minutes after it was written if nobody downloads it. A restart of the module deletes it too.
- Every step is in the audit log.
Download over HTTPS only, keep the file in a safe place, and delete it when you are done. See JVM.
AI data flow
AI help is optional and has three levels. Lens never calls a model unless an admin sets ai.enabled, the server has BoxLang+ or a trial, and the bx-ai module that ships inside Lens is present.
| Level | What leaves the server |
|---|---|
| Copy prompt | Nothing. The text goes to your clipboard. |
| Ask ChatGPT, Ask Claude | Nothing from the server. Your browser opens the site and you paste the prompt. |
Explain with AI, Ask (through bx-ai) | The prompt goes to the provider you configured. |
flowchart TD
A["Lens data<br/>stack frames, SQL text without parameter values,<br/>messages, health summary"] --> B["Redaction<br/>URL credentials and secret parameters removed<br/>cut at 8000 characters"]
B --> C["Prompt"]
C -->|Copy prompt| D["Your clipboard<br/>nothing leaves the server"]
C -->|Ask ChatGPT, Ask Claude| E["Your browser opens the site and you paste<br/>nothing from the server"]
C -->|Explain with AI, Ask| F{"ai.enabled,<br/>BoxLang+ or trial,<br/>bx-ai present?"}
Q["Question typed on Ask Lens<br/>sent as typed"] --> F
F -->|yes| G["The provider you configured<br/>receives the prompt"]
What a prompt holds is limited to data Lens has already redacted: stack frames, SQL text without parameter values, query strings with secret parameters hidden, short messages, and a summary of server health. Credentials in URLs and secret-looking parameters are removed from the whole prompt, and a prompt is cut at 8000 characters. Passwords, parameter values, scope contents and the configuration are not included.
Two limits you should know. Exception messages and SQL text are included as the application produced them, so data your code puts into a message is in the prompt. The question you type on the Ask Lens page is sent as you typed it.
The Lensy goes further: it sends tool results as well as questions, see the threat model. A local provider, such as Ollama, keeps the prompt inside your network. A hosted provider receives it, so check its terms. The API key is a bxsecret: value and is never shown. Calls are limited to 10 per minute and one at a time, and each is in the audit log without its content. See Ask Lens and AI help.
Lensy threat model
The Lensy lets a language model call tools on your server. Treat the model as untrusted, and what it reads as untrusted too.
What the assistant reads is sent to the provider. With a local Ollama that stays inside your network. With a hosted provider it does not.
MCP servers
An MCP server is code on another machine that Lensy can ask. It is a way for text to leave this server, and a way for text from outside to reach the model. Lens treats both as risks.
Channels
Notification channels post alerts and reports to Slack, Microsoft Teams, Telegram and your own webhooks. A channel is a way for text to leave this server, and an address an admin types is a way to point a server at the inside of the network. BxLens treats both as risks.
The developer setting dev.channelsLoopback lets a channel post to a loopback address over http. It exists for the end to end tests, it is off by default, and it can only be set in boxlang.json. Never turn it on in production.
The Secret Store
BxLens has one place for the secrets it must keep for itself (a password a feature has to send later, a token): the Secret Store. It is free on Free and Plus, and nothing in the console, the API, Lensy, the audit log, the logs or the diagnostic bundle ever returns a stored value. Features that use it: the console passwords, the AI key (ai/apikey) and the SMTP password (smtp/password). The last two are write only: an admin pastes the value in Settings (Assistant, Notifications or Security), it goes in and never comes out. They win over boxlang.json and over the environment variable, are audited as secret.change with the name only, and Lensy has no tool that reaches them. The console passwords are kept as salted slow hashes under the namespace auth, and the notification channels keep their webhook addresses, bot tokens and signing keys here.
How it works:
- Folder
secrets.dir(defaultconfig/bxlens-secretsin the BoxLang home) with two files:secrets.keyandsecrets.json. - Each value is sealed with AES-256-GCM, a new random IV every time, and its own name (
namespace/name) as associated data. A value copied to another name, or changed on disk, does not open. secrets.keyis 256 random bits, made once. Servers that start together share one key. The file is readable by its owner only, where the system allows.- Several servers can share the folder on a volume: a server reads
secrets.jsonagain when it changes, and a save is written under a file lock and replaces the file in one step. Links in the folder are never followed. - Limits: 500 secrets, 16 KB per value, 1 MB for the file. Names use
a-z,0-9,_,-and.. - With no key (the variable is wrong,
secrets.keyis damaged) a save is refused with "cannot save: no key". Plain text is never stored. - A wrong key or a changed value does not stop BxLens: that secret does not open, and the Storage tab, Secrets line, says "this server can open them: no". The name is logged once, never the value.
By default the key sits beside the data. That protects against a copied secrets.json, a backup of the data without the key, logs and screenshots. It does not protect against someone who holds the whole volume or can read as the user that runs BoxLang: they have the key too. To keep the key off the volume, set the environment variable BXLENS_SECRETS_KEY to 32 random bytes in base64 on every server (openssl rand -base64 32), from the secret store of your platform. Then a copy of the folder is useless without it. With several containers that share console sessions, the same variable also keys the hashes of the shared sessions, so set the same value on all of them (see Console sessions).
If the key is lost (the file is deleted, or the variable changes) the stored secrets cannot be opened and must be entered again. Back up the key together with the data only if you accept that a backup then holds both. Another key does not damage anything, the values just stay closed.
The diagnostic bundle never includes secrets.dir. The variable BXLENS_SECRETS_KEY is hidden by name wherever the environment is shown.
The diagnostic bundle
The bundle needs BoxLang+ or a trial. On Free the server answers 403. It is a zip for support tickets. It holds a thread dump, the environment (configuration, modules, JVM arguments, environment variables, system properties), the system, executor, task, datasource and cache data, and the Lens settings. It holds no request data, no log files and nothing from the Secret Store.
Secrets are hidden by name, not by value. A variable, property or setting whose name looks secret (password, token, key, secret, credential, cookie, session and similar) shows as [hidden], URL credentials are removed and bxsecret: values show as [encrypted]. A secret kept under a harmless name is not hidden. Look inside the zip before you send it. Only admins can download it, and each download is in the audit log.
Redaction
Lens masks values on the server before they reach the page. A key is masked when its name contains any redact.keys entry, compared case-insensitively. This covers scopes, request headers, response headers, query params, messages and panel data. The Cookie and Authorization headers are masked by default. In the console, sensitive keys in task definitions and in JVM flags are masked too.
{
"redact": {
"keys": [ "password", "pwd", "passwd", "token", "secret", "apikey", "api_key", "authorization", "cookie", "credential" ],
"mask": "[redacted]"
}
}
Add your own keys, for example ssn. Because matching is by substring, token also masks apiToken and csrfToken.
The Logs page does not redact. The Environment page and the diagnostic bundle hide secrets by name with a fixed check, described under The diagnostic bundle, not with redact.keys.
Size caps
limits.maxString (2000), limits.maxDepth (4) and limits.maxItems (100) cap every value sent to the page. Each collector also has a max count. These caps keep a large request from flooding the page.
Safe output
- Text from your app and from modules is always shown as text. The end to end suite checks that markup in messages, dumps and SQL never runs.
- JSON embedded in the page cannot be broken out of with a closing script tag.
- The bar adds one root element and makes no extra network requests.
- Panels contributed by modules and app code cannot supply HTML or script.
Security notes on your own pages
Lens also looks at your responses. Missing security headers and cookie flags show up as Notes in the console request detail. See Issues.
Checklist
- Keep
bar.enabledfalse in every shared or production config. - Turn the console on only with a
bxsecret:password, a tightconsole.accesslist and HTTPS (console.requireHttps: true). - Use
collect.level: "light"where real users send traffic. - Add your own sensitive keys to
redact.keys. - Leave the
cookie,session,request,applicationandvariablesscope dumps off unless you need them. - Set
console.actionstofalseif nobody should pause or run tasks from the console, andconsole.readOnlytotrueif nobody should change anything. - Give people who only look the viewer password.
- Behind a proxy, list it in
access.proxyPeers. - Leave
console.allowHeapDumpoff. - Keep
ai.enabledoff, or use a local provider. - Read
bxlens-audit.lognow and then. - Set
BXLENS_SECRETS_KEYfrom your secret manager on every server, so the key is not beside the data. Keep the key out of the backup that holdssecrets.json. - Keep the folders
store.dir,secrets.dirand the logs directory readable by the user that runs BoxLang and by your backup, and by nobody else. - Keep a
console.passwordinboxlang.jsoneven when you set passwords in the console: it is the way back in after a lockout.