This page answers one question: what can somebody do to an app when they control the markup, the CSS or the files it loads? For example when pages come from a remote server, and the server or the connection is in the wrong hands.
Short answer:
- Markup that the app ships (in its binary, its bundle or its own folder) is trusted. It can do what the app can do in the UI. That has not changed.
- Markup from anywhere else should be loaded as a document with a policy (
Ui::load_document, C:rfLoadDocument). It then runs in a sandbox. The rest of this page says what the sandbox stops and what it does not. - renderfi has no script language. Injected markup cannot run code by itself. A
<script>section runs only through a script host that the app registered, and a document that is not trusted runs none unless its policy lists the script type. What injected markup can do is draw, ask for files, and send actions to the app. Those three are what the sandbox controls.
Contents: the threat model, what the review found, what the bug hunt found, the sandbox, policy reference, signed bundles, the inspection protocol, what to do in your app, what is left.
Who attacks. Somebody who can change what the app loads: the markup of a remote page, a stylesheet, an image, a font, a bundle that is downloaded, a folder the user opens. They cannot run code on the computer (if they can, nothing here helps).
What they want.
| # | Threat | Example |
|---|---|---|
| 1 | Fake UI | A box over the whole window that looks like the app's login. |
| 2 | Trigger what the app can do | on-click="account.delete" on a large invisible box. |
| 3 | Read local files or the local network | <include src="file:///etc/passwd">, <image src="http://192.168.1.1/config">. |
| 4 | Send data out without scripts | CSS that loads a different image URL for each value of an attribute. |
| 5 | Reach native widgets | <file-picker path="/etc">, a widget of the app made with the attacker's attributes. |
| 6 | Stop the app | A tree nested 10000 deep, includes without end, an image that claims a billion pixels, a selector that takes minutes. |
| 7 | Scripts (when the app has a script host) | Markup with a <script> that makes a script host run something. |
| 8 | The inspection protocol | Use the tool socket of a shipped app to read and drive it. |
What is trusted. The app's code. Files loaded with load_markup, load_markup_file, set_stylesheet*, set_assets (the app's own bundle or folder). Fonts the app adds. The user's own account on the computer.
What is not trusted. Everything given to load_document. Every byte that comes over the network, also for trusted markup (an image URL in the app's own markup still gets an untrusted file).
The review read the markup and CSS parsers, the asset loader, the HTTP client, the image, font and SVG decoders, the bundle format, the C API, the language server config and the inspection protocol. Each row was a real hole. Each has a test that uses it (the test fails without the fix).
| Finding | Severity | Fix | Test |
|---|---|---|---|
Deep nesting ends the process. 50 KB of <box><box>... made the stack run out while the tree was built or laid out. |
High | The parser refuses nesting over 256 (rf_markup::MAX_DEPTH). The builder counts nesting over includes too. |
renderfi/tests/security.rs deep_nesting_cannot_end_the_process, nesting_counts_over_includes; rf-markup/tests/limits.rs |
A selector of 60 bytes takes seconds, a longer one never ends. .a b b b b b b b b x tried every way to spread its parts over the ancestors. |
High | The matcher stops when the parts further left found no place (rf-markup/src/selector.rs). Checked against the old matcher on random trees. |
rf-markup/tests/limits.rs |
| A redirect leaves the origin. A remote file may load only from its own origin, but a redirect from that origin led anywhere, also to the local network. The answer was shown as markup, CSS or an image. | High | rf-http asks a check about every URL, every redirect and every address it connects to (Request::check). Loads for remote files carry a same-origin check. |
security.rs a_redirect_cannot_leave_the_origin_of_a_remote_file; rf-http/tests/server.rs check_* |
A folder runs code when it is opened. The workspace file .lsp.toml could not set a server's command, but it could set its environment (LD_PRELOAD, PATH). |
High | env is read from the app's own settings file only. |
rf-lsp/src/config.rs a_workspace_cannot_set_the_environment |
| Tiny image files claim huge images. A 130 byte TIFF asked for 137 GiB (one tile of 65536 x 65536 for a 1 x 1 image). A 38 byte WebP, a 60 byte BMP, a 40 byte PSD and an 18 byte TGA asked for 4 to 13 GiB. | High | TIFF tiles must fit the image. DecodeOptions::max_pixels is checked before memory is taken; documents always set it; Ui::set_max_image_pixels sets it for the app's own loads. |
rf-image/tests/limits.rs |
SVG text ends the process. preserveAspectRatio="x" was sliced without a length check (a panic). A fill with a long chain of url() parts nested as deep as the attribute was long (the stack ran out). 1 KB of nested <use> around one long path made gigabytes of path data. |
High | A length check; one fallback after url(); a limit of 2 million path commands per SVG. |
rf-svg/src/tests.rs hostile_attributes_do_not_crash, use_cannot_multiply_a_long_path_without_end |
| Includes without end. A server that answers every include with markup that includes the next file kept the app loading for ever. | Medium | Includes nest 32 deep at most. | security.rs an_endless_include_chain_ends |
"Same origin" was true for origins that could not be read. From a file of an app's own URL scheme (app://), file:///etc/passwd and other hosts passed as the same origin and went to the app's fetcher. |
Medium | An origin that cannot be read is no origin. | renderfi/src/assets/tests.rs a_file_of_a_custom_scheme_stays_on_its_origin |
| A broken animation ends a worker thread. Frames after the first were decoded outside the guard that turns a decoder panic into an error. | Medium | The guard is around every frame. | covered by the fuzz test |
| The inspection socket (see below): text that was not JSON kept a connection open without the token; no limit on line length, idle connections or their number; the endpoint file was written through a file that was already there; a release build opened the socket when an environment variable said so. | Medium | All fixed. | rf-inspect/tests/protocol.rs |
| Warnings pile up. Every different warning was kept for ever to not repeat it. | Low | The lists have a limit. | security.rs warnings_do_not_pile_up |
Things the review checked and found in order:
- The markup parser uses no recursion and stops after 50 errors. The parser runs nothing: it keeps the text of a
<script>for the engine, which gives it to a script host only when the rules below allow it. - The bundle format (
.rfb): counts, offsets and paths are checked; paths cannot hold.., a leading/or a backslash; inflate never writes more than the size the index names. - Asset paths are normalized and cannot leave the asset root. A remote file cannot name a local file (
file://, absolute paths and..all resolve inside its own origin or are refused). - rf-http speaks only
httpandhttps(also after redirects), refuses user info in URLs, and limits header and body sizes. - Connections are kept and used again, and responses are kept in an HTTP cache that the app and its documents share. Two rules keep that safe. The address check runs for every request, also on a connection that is used again (libcurl tells the address each time; the other stacks look the host up before each request). And a request with a check gets from the cache only what a request with a check stored: a response that the app loaded from the local network is never given to a remote document. Responses to requests with credentials (
Authorization, cookies) are kept apart for each credential, never go to disk, and are forgotten at sign-out (Client::forget_account). - The language server config: the workspace file cannot set
commandorargs(now also notenv). - No untrusted byte reaches C code. The C rasterizer (fatmap) gets only our display lists: paths, paints and decoded pixels. Images, fonts and SVG are parsed by Rust code in this repository. No system codec is used. Two things to know: libcurl (and its TLS library) parses network bytes for HTTPS on Linux, and the macOS clipboard uses AppKit to convert a pasted TIFF.
A second pass (docs/reviews/2026-11-28-bug-hunt.md) attacked the sandbox itself. Each row was a real hole, is closed, and has a test that used it.
The tests are in renderfi/tests/bughunt_sandbox.rs unless the row names another file.
| Finding | Severity | Fix | Test |
|---|---|---|---|
A document sent any action to the app, with no click. on-error and on-load of an <include> or a <link> at the top of a document were sent with the container as their node. The container is a node of the app, so the allowlist let them pass. |
High | The allowlist is asked for the document that the markup belongs to, where the action is made, whatever its node is. | an_include_cannot_send_an_action_that_is_not_on_the_list, an_include_of_a_bundle_cannot_send_an_action_either, a_stylesheet_link_cannot_send_an_action_that_is_not_on_the_list, include_and_link_actions_follow_the_allowlist |
Pasted text sent the field's on-change past the allowlist. Ui::paste, insert_text, edit_command and set_field_html returned their actions without the filter. |
High | Every function of the UI that returns actions filters them. | pasted_text_and_edit_commands_follow_the_allowlist |
Widgets sent a document's actions past the allowlist. A widget library makes actions from the handler attributes of nodes (on-change of a checkbox) and gives them to the app itself. For a widget type on the policy's elements list, the name came from the document and nobody checked it. |
High | Ui::filter_document_actions; rf-widgets calls it for everything it hands out. |
rf-widgets/tests/sandbox_actions.rs |
position: fixed left the container. A fixed node is placed against the window, above the page and past every clip. A document could draw over the whole app and take its clicks. (The document fuzzer found the hit, seed 7063234.) |
High | A fixed node inside a document is placed like an absolute one: inside the container. | a_fixed_node_of_a_document_stays_inside_its_container |
Text without an address loaded any URL under DocumentPolicy::untrusted(), also from this computer and the local network. The rule "no base, no files" was only in the code for policies with origins. |
High | The file rules do not depend on origins any more (see threat 3). |
text_without_a_base_loads_no_files_under_the_untrusted_policy, a_text_document_asks_no_server_for_anything, a_local_document_without_an_origin_policy_stays_in_its_folder_and_off_the_network, renderfi/src/sandbox.rs the_file_rules_of_a_document |
A document read the bundle of another document with rfdoc1://b/file: the number counted up. |
High | Only the document that came from a bundle reads it, whatever the URL says. The scheme has a random number now. | a_document_cannot_read_the_bundle_of_another_document, a_claimed_bundle_address_opens_no_bundle |
CSS could still test attribute values. Only [a=b] in the outer part of a selector was dropped. [a^=b], [a=b i] and every form inside :not(), :is(), :where(), :has() passed. The prefix form reads a value one character at a time. |
Medium | The whole selector is walked; every form that reads a value is dropped. The length limit counts the parts inside the functions too. | all_value_selectors_are_dropped_without_the_policy_flag, value_selectors_follow_the_policy_flag, the_selector_limit_counts_the_parts_inside_functions |
@property of a document changed the app. A registered custom property holds for every node, so a document could switch off the inheritance of a variable the app uses. |
Medium | @property and @font-face of a document are dropped. |
a_document_registers_no_properties_and_loads_no_fonts |
An SVG multiplied memory and time. <use> of an embedded image decoded the image again for each copy (1.3 KB of text took 127 MiB; 6400 GB were possible). var() multiplied text without a limit (2 KB never ended). <use> of an <image> with SVG text inside parsed the text again for each copy. SVG text written inside a document's markup counted for no limit of the document. |
High | Each image file inside an SVG is decoded once and shared. All of them together may have 16 million pixels. var() has a limit for lookups (1024) and for the text it makes (64 KiB). One picture parses at most 8 MiB of SVG text inside images. SVG files and SVG text of a document count for its image_pixels and decoded_bytes. |
rf-render/tests/bughunt_svg_images.rs, rf-render/tests/svg_image_limits.rs, rf-svg/tests/bughunt_svg.rs var_cannot_multiply_text_without_end, rf-svg/tests/limits_nested.rs, svg_text_inside_a_document_counts_for_its_limits |
The pixel limit for pictures inside an SVG did not hold. rf_image::with_pixel_limit inside another call put the limit back to the largest value. The image registry makes such a call for every decode, so the limit that the SVG code set around it was lost. |
High | A call inside another call can only make the limit lower. | rf-render/tests/svg_image_limits.rs the_images_of_one_svg_share_a_pixel_limit |
| A document took images away from the app. The list of failed image URLs was one list for the app and all documents. An image that a document's own limit refused stayed broken for the app. | Medium | Failures are kept per document, and the list has a size limit. | an_image_refused_for_a_document_still_loads_for_the_app |
rf_inspect::list deleted a file that an endpoint file named. The path was text from the file, and the folder was not checked. In /tmp another local user can make the folder first. |
Medium (local) | See the inspection protocol. | rf-inspect/tests/bughunt_inspect.rs |
Closed from reading, without a test of their own:
autofocus(HTML preset) in a document took the keyboard focus when the document loaded. It is left out now, with a warning.- A popup that the policy lets out of the container (
popups) was no longer the document's for the allowlist. Popups are kept on the document's list now (Ui::adopt_into_document; rf-widgets does it). Test:a_popup_outside_the_container_is_still_the_documents. @nameactions (for the component around a node) were routed before the filter. With a component of the app as the container, a document could send the component's actions. Only a component inside the same document takes a document's@namenow.- Actions that waited for
take_actionswhen their document was unloaded passed, because their nodes were gone. Waiting actions of a document are checked when they are queued and again before the document's nodes go. - A client of the inspection socket could queue lines without a count limit before it showed the token. At most 16 lines now.
- The app side of the inspection folder set the permissions of an existing folder before it looked for a link.
ui.load_document(container, source, &policy)
container is a node of the app (a box with a size). source is markup text, an asset path or URL, or a bundle. Everything the document does from then on is checked against policy: also files it loads later and rows its repeats build later.
Trusted markup pays nothing for the sandbox: every check starts with a test that is false while no document is loaded.
What the sandbox does about each threat:
1. Fake UI: contained drawing. The container clips, whatever the styles say (the app's or the document's). The document cannot draw or take the pointer outside the container's box: not with position: absolute or fixed (a fixed node of a document is placed like an absolute one), negative offsets, huge sizes, transforms or shadows. Popups of widgets inside the document (menus, lists) are made inside the container too, unless the policy sets popups. A document cannot set modal (it would make the app around it inert), not as an attribute and not from CSS. It cannot take the keyboard focus by itself either (autofocus is left out): the user gives it the focus with a click or the Tab key. With badge, a frame and a label are drawn over the document: the document cannot hide them, because they are drawn after it.
The sandbox cannot stop a document from drawing a fake login inside its own box. Give remote content a box that does not look like the app's own dialogs, and use the badge.
2. Actions: an allowlist. Only action names on the policy's list reach the app, and only when the payload is of the listed kind. All others are dropped. Each dropped action is in ui.take_blocked_actions(), in the warnings, and visible to tools (Renderfi.getBlockedActions). Actions of the app's own nodes are never filtered.
The rule holds for every way an action is made: a click, a key, a drop, hover, on-load and on-error of includes, stylesheet links and images, text that is pasted or comes from an input method, edit commands, and the actions a widget makes for a node of the document. Every function of the UI that returns actions filters them (input, take_actions, activate, paste, insert_text, edit_command, set_field_html).
Code outside the core that makes actions from handler attributes itself must call ui.filter_document_actions(&mut actions) before it hands them to the app. rf-widgets does. A widget that makes a popup outside the container calls ui.adopt_into_document(popup, owner), so the popup stays the document's.
ui.find(id), ui.find_by_class and ui.select never return a node of a document, so a document cannot pass one of its nodes off as the app's node of the same id. Use ui.find_in_document(container, id) or ui.select_in(Some(container), ...) to look inside.
3. Files: a document stays where it came from. These rules hold for every document, with any policy, and for every way a document names a file (<include>, <link>, @import, <image>, <svg>, placeholders) and every redirect:
- markup text without a base loads no files at all;
- a document from a local asset path loads only files below its own folder, and nothing from the network;
- a remote document loads only from its own origin, and no local files;
- a bundle document reads only its own bundle, and only that document reads the bundle.
The origin policy (origins, optional) opens more, and adds checks:
- only the listed URL schemes load (default:
httpsonly); - the listed origins load too, also for a local document;
<include>takes markup from the document's own origin only, unlesscross_origin_includesis set; - hosts on this computer or the local network are refused (
localhost,127.x,10.x,172.16-31.x,192.168.x,169.254.x, IPv6 local ranges,.localnames, numbers in odd spellings like0x7f.1), unlessprivate_hostsis set. The address a name leads to is checked again when the connection is made, so a public name that points to a private address is caught too, and so is a redirect.
Nothing else loads files for a document: url() in its CSS names only pictures the app registered, @font-face is dropped, and an SVG shows only pictures that are inside its own text (data: URLs).
4. Data out through CSS. Two things are closed. Rules with a selector that reads the value of an attribute are dropped unless the policy sets attribute_selectors, so CSS cannot react to values. That is every form: [a=b], [a^=b], [a$=b], [a*=b], [a~=b], [a|=b], with or without the i flag, also inside :not(), :is(), :where(), :has() and :nth-child(... of S). [a] alone (is it set?) stays. And the document's rules cannot see the app's nodes at all: selector matching ends at the container. What is left: a document can load different URLs from its own allowed origins for :hover, :checked and the like, once background images exist. So its own server can learn what the user does inside the document. That is the same as on the web.
5. Native widgets: an allowlist. Only built-in elements are built (box, text, image, svg, input, textarea, span, b, i, code, repeat, include, canvas, splitter). Other element types (native widgets, components) need to be on the policy's elements list. A document cannot define components. Data bindings ({path}) work only for paths on the policy's data list.
6. Stopping the app: limits. Nodes, depth, includes, include depth, markup bytes, CSS bytes, selector length, image pixels and decoded bytes are limited (see the table below). The parser and the decoders check the limits while they work and stop there; nothing is built first and measured after.
SVG has limits of its own, for every SVG (also the app's): 200000 elements, 100000 shapes, 2 million path commands, 16 million pixels for all the pictures inside one SVG together (each file is decoded once, however often <use> shows it), 8 MiB of SVG text inside <image> elements, 1024 var() lookups and 64 KiB of text for one value. For a document, an SVG file and SVG text inside the markup count for image_pixels and decoded_bytes like an image.
7. Scripts: off unless the policy names the type. renderfi runs no code. An app can register script hosts for the <script type="..."> sections of its own markup. In a document that is not trusted, a <script> is an error: the document does not load, and the host never sees the text. A policy can allow script types by name (policy.scripts, allow_script("text/angelscript")). An allowed script is written inside the element (src loads no file), and its type still needs a registered host. renderfi cannot limit what script code does. So the host must take the script's rights from the policy: policy.capabilities and ui.document_capabilities(node). The host sees which document a section is in (ScriptSection::document, RfScriptInfo.document). Do not list a type if its host cannot keep a script inside those rights. Actions of the document go to its scripts first. An action that no script takes still needs to be on the policy's action list. See guide/scripting.md.
Style isolation. The document's CSS styles only the document's nodes. It uses the scope scheme of components: the container is the host of the document's nodes, the document's sheets have the document's scope number, and :host and ::part() rules are dropped (they would reach the container). The app's CSS styles the document only when the policy sets app_styles. Inherited values (font, color, CSS variables) always come in from the container. @keyframes of a document never replace the app's keyframes of the same name. @property and @font-face of a document are dropped: both would change the whole app.
DocumentPolicy::untrusted() (the same as default()) allows the least. Rust fields, with the C field or flag of RfDocumentPolicy:
| Field | Default | Meaning |
|---|---|---|
elements (elements) |
none | Element types allowed besides the built-in ones. |
actions (actions) |
none | Action names that reach the app, each with a payload kind: None, Text(max bytes), Number, Any. A name ending in * allows every name with that start. In C: name, name:text, name:number, name:any. |
data (dataPaths) |
none | Data paths the document may bind to. |
origins (RF_DOCUMENT_ORIGIN_POLICY_BIT) |
off | The origin policy, see below. Off: the document loads only from where it came from (its origin, its folder, its bundle; text without a base loads nothing). |
popups (RF_DOCUMENT_POPUPS_BIT) |
false | Popups may leave the container. |
badge (badge) |
none | A frame and this label over the document. |
app_styles (RF_DOCUMENT_APP_STYLES_BIT) |
false | The app's stylesheets style the document too. |
attribute_selectors (RF_DOCUMENT_ATTRIBUTE_SELECTORS_BIT) |
false | Selectors that read the value of an attribute work ([attr=value], [attr^=value], ...). |
signer (pSignerKey) |
none | A bundle must be signed with this key. |
capabilities (capabilities) |
none | For script hosts. |
scripts (scripts) |
none | The MIME types of <script> sections that may run. Empty: a <script> is an error. |
limits |
see below |
OriginPolicy::same_origin():
| Field | Default | Meaning |
|---|---|---|
schemes (schemes) |
https |
URL schemes that load. |
origins (origins) |
none | Other origins that load, like https://cdn.example.com. |
cross_origin_includes (RF_DOCUMENT_CROSS_ORIGIN_INCLUDES_BIT) |
false | <include> may take markup from those other origins. |
private_hosts (RF_DOCUMENT_PRIVATE_HOSTS_BIT) |
false | Hosts on this computer or the local network load. |
DocumentLimits:
| Field | Default | Checked |
|---|---|---|
markup_bytes |
1 MiB | before a markup file is parsed |
nodes |
10000 | by the parser, and when nodes are built |
depth |
64 | by the parser (never over 256) |
includes |
16 | before an include is loaded |
include_depth |
4 | before an include is loaded |
stylesheet_bytes |
256 KiB | by the parser (<style>), and when a linked file arrives |
selector_parts |
8 | when a sheet is taken; longer rules are dropped. The parts inside :is(), :not(), :where(), :has() count too |
image_pixels |
16 million | by the image decoder, before it takes memory. For an SVG: all the pictures inside it together |
decoded_bytes |
256 MiB | before an image is decoded, for all images of the document. An SVG counts with its paths and the pixels inside it |
fonts |
0 | documents cannot load fonts (@font-face in a document's CSS is dropped) |
Nesting limits. They hold for all text, not only for documents, and no policy changes them. The parsers call themselves once per level, so text from outside must not choose the depth.
| What | Limit | Deeper input |
|---|---|---|
Brackets in a CSS value, a condition of @media, @supports or @container |
32 | the declaration or the rule is skipped, with an error |
:is(), :not(), :where(), :has() inside each other |
32 | the rule is skipped, with an error |
{} blocks inside each other (nested rules and at-rules) |
32 | the block is skipped, with an error |
Terms of one calc() |
256 | the value is not valid |
| Custom properties of one element that name each other in a chain | 64 | the value is not valid, like a missing variable |
| Markdown: quotes and lists inside each other | 32 | read as paragraph text |
| TeX and MathML formulas | about 100 levels | a parse error |
| Regex groups | 50, and 16 repeats in a row | a pattern error |
| D-Bus values | 64 (the D-Bus rule) | a protocol error |
| Dock layout text: splits | 64 | restore gives an error and changes nothing |
Size limits of pictures: a CPU surface has at most 32767 pixels on a side. render_to_image gives InvalidInput for a larger picture, a render target is made 32767 pixels at most (with a warning in the log), and an image with a larger side is not drawn. A blur is at most 10000 px.
Functions:
| Rust | C | |
|---|---|---|
ui.load_document(container, source, &policy) |
rfLoadDocument |
Load. On an error the container is empty. |
ui.unload_document(container) |
rfUnloadDocument |
Take the document away. |
ui.document_of(node) |
rfGetDocument |
The container of the document a node is in. |
ui.find_in_document(container, id), ui.select_in(Some(container), ...) |
rfQuerySelectorAll with the container as scope |
Find nodes of the document. |
ui.take_blocked_actions(), ui.blocked_actions() |
warnings | Dropped actions. |
ui.filter_document_actions(&mut actions) |
For code that makes actions from handler attributes itself (a widget library). | |
ui.adopt_into_document(node, owner) |
A popup outside the container stays part of the owner's document. | |
ui.document_capabilities(node) |
For script hosts. | |
ui.set_max_image_pixels(Some(n)) |
The pixel limit for the app's own image loads. |
An app can refuse every bundle that it did not sign.
scripts/sign_bundle.sh keygen mykey # mykey.key (secret), mykey.pub (64 hex digits)
rf-bundle pack ui -o ui.rfb
scripts/sign_bundle.sh ui.rfb mykey.key # adds the signature
scripts/sign_bundle.sh verify ui.rfb mykey.pub
Put the 32 bytes of mykey.pub in the app. Keep mykey.key out of the app and out of version control.
- As the app's assets:
BundleAssets::from_signed_rfb(bytes, &key), C:rfSetAssetBundleSigned. The C function does not look atRF_ASSETS_DIR: a folder has no signature. - As a document:
DocumentPolicy::untrusted().signed_by(key)withDocumentSource::Bundle. Markup text and files are then refused, because they carry no signature.
The signature is Ed25519 over the whole archive, in a 72 byte trailer. Nothing of the archive is parsed before the signature is checked. Ed25519 and SHA-512 are written in crates/rf-bundle (no outside crates) and tested against the vectors of RFC 8032. Signing runs the same steps for every key (no branch or table index depends on secret bits). Checking is strict: point encodings must be canonical and S must be below the group order.
A signature says who made the bundle. It does not make the content safe: sign only what you would ship.
rf-inspect lets a tool read the UI and click and type in it. In the wrong hands that is a remote control, so:
- Off in release builds, whatever the environment says, unless the app turns it on in code:
rf_app::tools::Protocol::LocalOnlyInRelease(C:RF_INSPECT_PROTOCOL_LOCAL_ONLY_IN_RELEASE). (The modeler and vterm apps do it only when started with--inspect.) A debug build opens it in debug and editor mode.RF_TOOLS=1, which puts the developer tools into an app with no code, follows the same rule: in a release build it gives the tools in the window, never the socket. - Local only. A Unix socket in the user's folder, or TCP on 127.0.0.1. A peer that is not local is refused. A tool ignores an endpoint file that names another host, so it never sends a token over the network.
- A token. 128 random bits, new at each start, in an endpoint file that only the user can read (mode 0600, in a folder of mode 0700). The folder must be a real folder of the user: a link, a folder of another user, or one that others can open is refused. The endpoint file is always made new, never written through a file that is already there.
- Nothing before the token. The first line of a connection must be
Inspector.attachwith the token, compared in constant time. Anything else gets one error and the connection ends. That includes what a web page can make a browser send to a local port. - Limits. 5 seconds to show the token, 4 KiB for the first line, 16 lines before the token was seen, 8 MiB per line, 16 connections.
- Tools trust only the user's own folder.
rf_inspect::listmakes the same check of the folder as the app side: a real folder of this user that is closed to others. From any other folder it reads nothing and removes nothing. It removes only two kinds of file, both made by an app of this user in that folder: an endpoint file (a plain.jsonfile, no link) of an app that no longer answers, and that app's Unix socket. A path that an endpoint file names is removed only when it is a socket, directly in the folder, of this user. Never a plain file, a folder, a link or a path outside.
Whoever has the token can do what the user can do in the app's UI. Do not turn the protocol on where other programs of the same user are not trusted.
The remote listener (an app on a phone, the tools on the desktop; guide: Remote devices) is the one way in from another computer. Its rules:
- Not in a shipped build. The listener and its pairing code are compiled only in debug builds and with rf-app's feature
remote-inspect(rf_inspect::REMOTE_BUILT). A release build without the feature has no such code: no environment variable and no call opens it.cargo tree -p yourapp -e features,no-dev -i rf-inspect | grep remotemust print nothing for what you ship. - Only when asked. At run time it needs
RF_INSPECT=remote(the device's own 127.0.0.1: a port forwarded over USB) orRF_INSPECT=lan(one address of the local network). It binds that one address, never all of them. Onlana peer must have a private, link-local or loopback address. - A pairing code, proved and never sent. Six digits that the app shows on its screen. A client attaches with HMAC-SHA256 of two nonces under the code, the app answers with its own proof, and the client gets a session token for later connections. The token of the endpoint file opens nothing on this listener. A code works once; five wrong proofs make a new code and lock pairing for 30 seconds, then twice as long each time (15 minutes at most). The other limits are those of the local socket.
- Not encrypted. There is no TLS yet. Somebody who can read the network can read the data. Somebody who records a pairing can try all million codes against the proof offline, find the session token and drive the app. So
lanis for a network you trust and for development builds; over USB nothing goes over the air. On a network where others can also change packets, nothing here helps: use USB. - What a paired client can do is what a local client can do: read the UI, click and type, read the log lines and the trace.
The inspector in its own program (rf-inspect-ui) is one more client of the same socket: it finds the endpoint file, shows the token, and asks for the app's picture (Page.captureFrame) and log lines (Log.getEntries). It opens no socket of its own, so it changes none of the rules above. The log lines can hold what the app writes into them: the app's own log text goes only to clients that have the token.
- Decide what is trusted. Markup you ship is. Markup from a server, a user or a plugin is not: load it with
load_document. - Start from
DocumentPolicy::untrusted()and add only what the content needs. List the few actions it may send; check their payloads in your handler too. - Set the origin policy for remote documents:
OriginPolicy::same_origin(), plus the origins you serve images from. Keephttpsonly and private hosts off. - Use HTTPS and, when you can, signed bundles. A page over plain HTTP can be changed by anyone on the network.
- Show that it is remote: the badge, and a container that does not look like your own dialogs. Never ask for a password inside remote content.
- Keep widgets off the list unless they are safe with any attribute. A widget that takes a path, a URL or a command is not.
- Give no data paths that hold secrets. A bound value is in the document's tree.
- Set
ui.set_max_image_pixelswhen your own markup shows images from URLs. - A custom URL source (
AssetSource) should implementrequest_checkedand ask the check about every redirect and address. The default asks only about the first URL. - Opening folders (code editor): pass no workspace to
rf_lsp::Config::loadfor folders you do not trust. See below. - Leave the inspection protocol off in what you ship.
The example examples/remote_ui does 1 to 5; the guide section is Loading remote UI safely.
Known limits, most important first. None of them lets a document run code, leave its container or reach the app's actions; most are ways to use memory or time.
- Phishing inside the container. See threat 1. The badge and the app's layout are the defence.
- A document's own server sees what happens in the document. It serves the files, so it sees which ones are asked for. With images loaded by state (
:hover), that is also what the user does there. - Time. There is no time budget. A document inside its limits can still be slow to lay out, or animate for ever. The limits bound the work per frame; they do not bound the frames.
- The app's own image loads have no pixel limit by default (2^30 pixels, 4 GiB). Animations have no frame limit there either. Set
ui.set_max_image_pixels. Documents are limited. - Decoder work that was read but not tested here (reported by the review, no test yet): a progressive JPEG with very many scans costs CPU until the load is cancelled; TIFF with LZW can grow 3600 times; a GIF frame can be much larger than its screen; a WebP can ask for many Huffman tables (about 330 MB). Under a document's pixel limit the sizes are bounded; the CPU cases are not.
- Fonts. A hostile font can make the layout tables take about 1 GiB (lookups that all point at one table) and make one glyph very slow (composites of huge glyphs). Documents cannot load fonts. Do not add fonts from places you do not trust.
- Language servers. The workspace file can still set
optionsandsettings, which go to the server as they are. Some servers read command lines from them (rust-analyzer'soverrideCommand). Many servers also run code of the project by design (build scripts). Treat "open a folder with a language server" as "trust the folder". An app should ask the user first. - HTTPS on Windows, macOS and Android (none run yet). WinHTTP, Foundation and Java's
HttpURLConnection(Android) do not say which address they connect to. There the name is looked up and checked before the request (a name that changes its address between the two is not caught), WinHTTP follows no redirect for a checked load, Foundation's redirects are checked only after the request was made, and on Android each redirect is checked before it is followed (rf-http and rf-net follow them, not Java). Android's WebSockets check the real address. On Linux (libcurl 7.80 or newer) and for plain HTTP the real address is checked. A proxy hides the address from all of them. - One request per URL, one picture per name. When the app and a document ask for the same URL at the same time, they share the request, and the document gets the answer of the app's unchecked request. The URL itself passed the document's policy. A picture that the app loaded or registered under a name shows in a document that names it (
<image src="name">,background-image: url(name)), also one that the document's own limits would refuse. The document can show it inside its box; it cannot read it. - Cascade layers have one name space.
@layernames of a document and of the app are the same names. A document's CSS still styles only its own nodes, but withapp_stylesit can name the app's layers. - Rows of repeats are not counted against the node limit (the app's data decides how many there are). Only for documents with data paths.
- Allowed widgets get the document's attributes. Each widget on the list must be safe with any value.
RF_ASSETS_DIRreplaces the app's bundle with a folder (development). Who controls the environment controls the app's own markup. Signed assets (rfSetAssetBundleSigned,set_assets) do not use it.- The inspection token comes from the hash keys of the standard library (seeded from the system's random source), not read from the system directly.
- The
rf-bundle unpacktool accepts a path with a drive letter on Windows. Unpack only bundles you made. - 32-bit targets were not reviewed for size products that wrap.
- The C rasterizer was not reviewed for extreme coordinates or dash patterns (an SVG can pass a tiny dash length).
crates/renderfi/tests/fuzz_documents.rs loads random documents (markup, CSS, includes, SVG and damaged images from a fake loader where every path has a file) under random policies. For each one it checks: no panic; the limits hold; the picture outside the container is the same as without the document; no point outside it hits a node of the document; no action leaves that is not on the list; the app's own styles are as before; unloading leaves the app as it was.
The actions are checked for every way they can leave: the ones of the document's nodes and the ones sent with the container as their node.
To see the document of a failing seed: RF_FUZZ_DUMP=1 RF_FUZZ_SEED=n RF_FUZZ_ITERS=1 ... -- --nocapture.
It runs 400 documents in the normal test run. A long run:
RF_CASES=200000 RF_SEED=1 cargo test --release -p renderfi --test fuzz_documents -- --nocapture