Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
db1afe5
Add an optional integrated TLS 1.3 server (#631)
ambroise-leclerc Nov 21, 2026
38b26b3
Implement TLS primitives directly from the specifications (#631)
ambroise-leclerc Nov 21, 2026
3e421b7
Preserve explicit remote reads and harden TLS lifecycle (#631)
ambroise-leclerc Nov 21, 2026
807db48
Compile the optional TLS provider on every desktop (#631)
ambroise-leclerc Nov 21, 2026
e1157f2
Finish orderly WSS closure and preserve masked curve selection (#631)
ambroise-leclerc Nov 21, 2026
9bec337
Show the off-loopback TLS warning with default logging (#631)
ambroise-leclerc Nov 21, 2026
c3f3875
Bound TLS negotiation and drain secure WebSocket closure (#631)
ambroise-leclerc Nov 21, 2026
c9f0e30
Keep PSK fixture iterator arithmetic signedness-safe (#631)
ambroise-leclerc Nov 21, 2026
9cf9c4a
Preserve braced ReadBinding construction with typed options (#631)
ambroise-leclerc Nov 21, 2026
1b0608d
Report TLS handshake failures and document closure semantics (#631)
ambroise-leclerc Nov 21, 2026
83c5069
Cap concurrent TLS handshakes per listener (#631)
ambroise-leclerc Nov 21, 2026
3e1043c
Verify the default HTTP browser URL and relax TLS test guards (#631)
ambroise-leclerc Nov 21, 2026
e882687
Check the ALPN alert in the OpenSSL record trace (#631)
ambroise-leclerc Nov 21, 2026
1795691
Split the TLS handshake coroutine for MSVC and harden Receive (#631)
ambroise-leclerc Nov 21, 2026
9294355
Follow RFC 8446 on key_share, plaintext record version, KeyUpdate and…
ambroise-leclerc Nov 21, 2026
eeced78
Bound the WSS close drain and drop the stdexec-only handshake race (#…
ambroise-leclerc Nov 21, 2026
66bf5b7
Silence MSVC C4737 for the TLS handshake coroutines (#631)
ambroise-leclerc Nov 21, 2026
e61bcb0
Build the TLS handshake stages unoptimized on MSVC (#631)
ambroise-leclerc Nov 21, 2026
3d31864
Keep the server Finished expression out of the co_await (#631)
ambroise-leclerc Nov 21, 2026
fe5e497
Reject a concurrent TLS Send in release builds and keep the Poly1305 …
ambroise-leclerc Nov 21, 2026
88a26e7
Bound the wait of a write blocked when a TLS peer sends close_notify …
ambroise-leclerc Nov 21, 2026
37ec84f
Address review of the integrated TLS server (#631)
ambroise-leclerc Nov 21, 2026
516e3af
Accept TLS 1.3 record padding before bounding the content (#631)
ambroise-leclerc Nov 21, 2026
a2f15ca
Drop every TLS 1.3 compatibility ChangeCipherSpec of the handshake wi…
ambroise-leclerc Nov 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ CI exercises C++ and native-browser paths on Windows, macOS and Linux. Extended
- Development project access is explicit and intended for trusted local code. Downloaded tools run with the application's bridge authority, and script permissions frame only the `context` API: neither is a sandbox. Only packages that run in a browser are supported; installation scripts and native add-ons are not executed. Builds transform TypeScript without type checking; `wf check` type-checks with the compiler the project locks.
- An opt-in [native pseudoterminal](docs/PTY.md) connects an application-selected program to xterm.js on Linux, macOS and Windows.
- The optional [`@webfront/react` adapter](docs/REACT.md) supplies coalesced C++ stores and empty React islands. `WebFrontLifeReact` demonstrates a C++ panel within the Game of Life React UI; its package archive is prepared locally for registry publication.
- Embedded Linux has ARM64 CI coverage and specific Orin Nano board evidence; other boards, bare-metal targets and microcontrollers are not generally qualified. Check C++23, memory, networking and browser requirements for your target. The default local transport supplies neither TLS nor client authentication; remote deployment needs an application-specific security design.
- Embedded Linux has ARM64 CI coverage and specific Orin Nano board evidence; other boards, bare-metal targets and microcontrollers are not generally qualified. Check C++23, memory, networking and browser requirements for your target. For HTTPS and WSS, see the [optional TLS listener and remote deployment recipe](docs/TLS.md). Client authentication is an application responsibility.
- Packaging, accessibility and native-engine deployment still need application-specific work. The optional [`ui.document()` API](docs/DOM.md) provides DOM islands, automatically batched writes, event callbacks and grouped sender reads. See [project status](docs/PROJECT_STATUS.md) for known limitations.

## License
Expand Down
1 change: 1 addition & 0 deletions cmake/CompilerWarnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function(set_project_warnings project_name)
/w14906 # string literal cast to 'LPWSTR'
/w14928 # illegal copy-initialization; more than one user-defined conversion has been implicitly applied
/wd4714 # '__forceinline' function not inlined: stdexec's coroutine helpers, which are not ours to change
/wd4737 # 'Unable to perform required tail call': MSVC cannot chain the long awaits of the TLS handshake coroutines; a performance note only
/analyze # Enable Code Analysis
/analyze:external- # Disable Code Analysis for external headers
/analyze:stacksize65536 # Raise C6262 stack warning threshold to 64KB (policy buffers can reach 32KB); one argument, as sccache reads a separate "65536" as a second source file and refuses to cache the compilation
Expand Down
2 changes: 1 addition & 1 deletion docs/AUTOMATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ two-second handshake deadline); they do not consume the 32 authenticated request
This prevents silent connections from exhausting that worker pool. A sustained local flood can
still deny service through OS or CPU resource exhaustion. Attached clients wait up to 30 seconds
for each response; `--request-timeout 1..3600` changes this independently of the operation and
startup deadlines. CLI result polling backs off from 50 ms to one second. There is no TLS or remote/multi-user authentication promise.
startup deadlines. CLI result polling backs off from 50 ms to one second. The automation channel remains local. The optional [TLS listener](TLS.md) serves the application UI and bridge.
Listening, accepted and client sockets are non-inheritable; POSIX closes them on exec. The page
capability uses the same OS cryptographic generator and comparison as the attachment channel.

Expand Down
2 changes: 2 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ these entries stays in the GitHub releases and the Git history.
- The CEF profile is now `cef_cache/<executable>`, not `cef_cache`: an application starts with an empty profile (localStorage, cookies); to keep the data, move the old contents of `cef_cache` into `cef_cache/<executable>` once (#617, `docs/HOST_INTEGRATION.md`).

### Added
- Use a custom network provider with `DeveloperAppWithNetwork`. The `BasicDeveloperApp` alias selects the existing TCP provider (#631).
- Serve HTTPS and WSS with the optional header-only TLS 1.3 listener and reload its PEM identity after renewal (#631, `docs/TLS.md`).
- Start an application with no port setting when `9002` is taken: an empty `WebFrontConfig::port` falls back to a free port, a chosen port is never replaced, and CEF and WebKitGTK give each live instance its own profile directory (#617, `docs/HOST_INTEGRATION.md`).
- Start several applications side by side: the default port follows `WEBFRONT_PORT` (a number from 0 to 65535, `0` asks for a free port, `9002` remains the default), the examples take `--port`, the server announces the port really bound, and a failed bind names the address, the port and the cause (#617, `docs/HOST_INTEGRATION.md`).
- Run the MSVC code analysis in a pull request into `develop` that changes Windows code, and list the reruns each job needed before going green with `FlakeReport.py --days` (#628, `docs/TEST_TIERS.md`, `docs/TEST_PERFORMANCE.md`).
Expand Down
5 changes: 3 additions & 2 deletions docs/CONTENT_POLICY.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ WebView2 still reports failures to read popup event data or mark it handled as s

This is a top-level navigation policy, not a subresource/iframe/network sandbox. Frames, fetches,
third-party scripts, downloads, OS protocol handlers and browser extensions need separate host
controls. A same-origin script already has the application's bridge authority. The server exposes
no TLS or user authentication. Keep the default loopback bind unless remote access is deliberate.
controls. A same-origin script already has the application's bridge authority. The optional [TLS listener](TLS.md)
protects the transport and authenticates the server. The application owns client authentication.
Keep the default loopback bind unless remote access is deliberate.
DevTools settings control the adapter's engine UI, not inspection by native host code or an external debugger.

Custom frontends can opt into `open(address, port, page, const ContentPolicy&)`; `BasicWF` prefers
Expand Down
4 changes: 3 additions & 1 deletion docs/PROJECT_STATUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ are retained for investigation; diagnostics alone do not establish a correction.
- The developer environment and `NativeDebugFS` are trusted development facilities, not sandboxes.
Manifest permissions bound only the scripts' `context` API. Only browser packages install;
installation scripts and native add-ons do not run. The [content policy](CONTENT_POLICY.md)
restricts browser origins and navigation but provides neither TLS nor client authentication.
restricts browser origins and navigation. The optional [TLS listener](TLS.md) adds HTTPS and WSS
with TLS 1.3 and ChaCha20-Poly1305. Each listener admits 16 concurrent handshakes on the I/O thread.
Client authentication remains an application responsibility.
- `fs::NativeStorage` confines writable storage to a declared root while resolving each path, but
on POSIX it cannot prevent the effective user or the superuser from moving a directory out of the
root during an operation: it detects such a move before a commit and after each operation, at
Expand Down
129 changes: 129 additions & 0 deletions docs/TLS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Serving HTTPS directly

Include `<webfront/tls/WebFront.hpp>` and use `webfront::tls::WebFront<>` for a
TLS-only listener. It serves HTTP/1.1 and the WebFront bridge over WSS on the same port.
The component is header-only and links without a TLS library.

> The TLS profile is proposed and its constant-time behavior has not been audited.
> Limit access to controlled networks while it is being qualified. For an
> Internet-facing listener, use a deployment proxy with connection admission
> controls and handshake deadlines.

```cpp
#include <webfront/tls/WebFront.hpp>

int main() {
auto credentials = std::make_shared<webfront::tls::Credentials>(
"/path/to/fullchain.pem", "/path/to/privkey.pem");
webfront::tls::WebFront app({
.address = "127.0.0.1",
.port = "8443",
.contentPolicy = {.allowMissingOrigin = false},
.tlsCredentials = credentials,
});
app.cppFunction("greeting", [] { return std::string("Hello over HTTPS"); });
app.run();
}
```

Use an ECDSA P-256 leaf certificate whose SAN covers the DNS name users visit.
Supply the PEM chain in leaf-first order and an unencrypted PEM private key
as a single `PRIVATE KEY` (PKCS#8) or `EC PRIVATE KEY` (SEC1) block. The files
accept whitespace around the PEM blocks. Extra text such as `Bag Attributes`
and separate `EC PARAMETERS` blocks are refused. To generate a single SEC1
block, use `openssl ecparam -name prime256v1 -genkey -noout -out privkey.pem`.
Give the application account read access to the key.
WebFront checks the structure of each certificate and that the leaf matches the
private key, but not validity dates or the chain's trust: the browser does.
After the certificate manager has written both renewed files, call
`credentials->reload(fullchain, privkey)` from the application's renewal hook.
It checks that the leaf and key match before publishing them to new handshakes.
A failed reload throws and preserves the active identity. Existing connections
continue with their negotiated keys.

Open the deployment URL in the browser. When using `show()` on a local bind,
the certificate must cover the configured address used in the window URL.
`start()` (return at once, system browser) needs a frontend that provides
`launchHttps(address, port, page)`; today only `DefaultBrowserFrontend`, the
default, does. With another frontend, `start()` fails to compile; use `show()`
or open the URL yourself.
The browser verifies the certificate chain and server name. WebFront applies
the usual bridge origin policy. The file-service binding cookie carries `Secure`.
File reads for non-associated clients require an explicit `remoteFileTransport`
declaration, typically `httpsByDeployment`. The default `refused` applies to
TLS listeners as well. Client authentication and authorization belong to the
application. A non-browser client can supply its own `Origin` header. The
example requires the header so requests without one are refused.

The initial profile negotiates TLS 1.3, X25519, ECDSA P-256 with SHA-256 and
`TLS_CHACHA20_POLY1305_SHA256`. Clients must offer this suite. The profile
uses full handshakes and HTTP/1.1. If a client sends ALPN, it must offer
`http/1.1`. An ALPN offer without it is rejected with `no_application_protocol`
(alert 120). Where clients require AES-GCM, HTTP/2,
or another certificate type, terminate TLS at the deployment proxy and
configure `httpsByDeployment` if file-service reads are enabled.
Client 0-RTT ciphertext offered with a PSK is discarded, up to 64 KiB.

The handshake parser limits ClientHello to 64 KiB and 128 extensions, and the
receive buffer to 16,640 bytes of ciphertext. Incoming handshake messages may
span records, with one message at a time. The server supports the ClientHello,
optional second ClientHello and Finished sequence described in the
[decision record](adr/ADR-024-tls-integre.md).

Each listener admits up to 16 concurrent TLS handshakes, with a ten-second
deadline from accept through Finished. When all slots are occupied, a newly
accepted socket is closed immediately. Established connections release their
slot. The two X25519 operations and the CertificateVerify signature run on
the I/O thread. A sustained rate of incoming handshakes can saturate that
thread and cause denial of service, including for established HTTP/WSS
connections. The limit of 16 bounds the work in progress, not an attacker's
reach: sixteen idle connections keep every slot for up to ten seconds and can be
renewed, so it is not a defence against denial of service. Put a rate limiter or
a firewall in front of an exposed listener. WebFront writes a warning to standard error when the integrated
listener is configured outside loopback. Enable
`log::Debug` with a log sink to see handshake failure reasons and error codes.

On orderly WSS closure initiated by the peer, WebFront answers the WebSocket
Close frame and then sends TLS `close_notify`. The secure queue retains the
active frame and discards other queued frames and subsequent writes once the
peer's Close is accepted. The TCP queue follows its existing stop behavior.
If TLS closure is requested during a send, the alert follows the current
complete TLS record. Local `stop()` during a write can cancel that record,
so the peer sees a truncated TLS stream without `close_notify`. A reset or
failed write can also prevent the alert from being sent.

A peer's `KeyUpdate(update_requested)` is answered before the next
application data record. The response stays pending while the server is idle.

When using `tls::Server` directly, run handshakes for each acceptor on its I/O
thread and serialize `Send` calls on each socket. HTTP and WebSocket enforce
this contract when using `tls::WebFront`.

## Constant-time regression

On Linux with GCC or Clang, Valgrind and its development headers installed, the optional
`TLSConstantTime` CTest case marks the private inputs to `p256Base` and `x25519`
undefined and checks compiler-generated branches and addresses with Memcheck.
The probe passed locally on x86-64 with GCC 16.1 and Clang 21 at `-Os` and `-O3`.
The probe covers those scalar operations and compiler configurations. It leaves
an audit of the rest of TLS and other targets, including Thumb-2, outstanding.

## Size, memory and handshake time

On Linux x86-64 with GCC 16.1, a minimal app with one bridge callback built at
`-Os -DNDEBUG -ffunction-sections -fdata-sections -Wl,--gc-sections` gained
47.3 KiB of `.text` and 5.5 KiB of `.rodata` when the TCP provider was
replaced by the TLS provider. The TLS headers total about 1,500 lines, including the in-tree primitives and comments.

In the same binaries, 200 open loopback WebSockets increased Linux
`smaps_rollup` private dirty memory by about 3.5 KiB more per idle connection
for WSS than for WS. Giving each socket 16,384 bytes of an incomplete frame
increased the WSS overhead to about 18.8 KiB per connection. These are process
measurements after a warm-up connection and include allocator overhead.
Thumb-2 size and peak memory during the handshake remain unmeasured.

On an AMD Ryzen 9 3900X, an OpenSSL-backed Python client completed 200
sequential loopback handshakes in 2.0 ms at the median and 2.2 ms at the 95th
percentile. The measurement starts after TCP connect and ends after TLS
negotiation, following ten warm-up connections. It includes both endpoints
and excludes HTTP traffic.
4 changes: 3 additions & 1 deletion docs/adr/ADR-008-contenu-de-confiance-et-origines.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ peut forger cet en-tête. `Host` ne donne pas une permission de bridge.
Que les dérogations de développement demeurent explicites. DevTools et menus restent activés
par défaut. Le navigateur système contrôle sa propre navigation ; le serveur y applique néanmoins
le contrôle du bridge. Les capacités des moteurs diffèrent, notamment les popups WKWebView.
WebFront cible du contenu de confiance, sans TLS ni authentification intégrés.
WebFront cible du contenu de confiance. Le TLS optionnel ([ADR-024](ADR-024-tls-integre.md)) protège la confidentialité
et l'intégrité du transport. Il authentifie le serveur auprès du navigateur. Le contrôle d'origine reste seul juge
de l'accès au pont et WebFront ne fournit pas d'authentification des clients.

Que le secret de lancement d'une vue intégrée (#453) ne s'ajoute pas au contrôle d'origine : il ne donne aucun accès
au pont, que le contrôle d'`Origin` règle seul. Il ne sert qu'à savoir si la connexion vient de la vue de
Expand Down
4 changes: 3 additions & 1 deletion docs/adr/ADR-010-composants-et-outils-optionnels.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Le terminal édite les lignes dans le navigateur et appelle les commandes C++. L
navigateur peuvent traiter une commande ou la laisser continuer côté C++. Leurs interruptions
ne promettent pas d’arrêter une commande C++.

Le TLS serveur est un composant hors du cœur ([ADR-024](ADR-024-tls-integre.md)).

Pour `wf`, HTTPS et vérification SHA-512 se font dans le navigateur. C++ valide les chemins,
reçoit les chunks séquentiels et installe via staging puis commit. `ToolStore` conserve
`webfront-tools.lock.json` et les fichiers sous `.webfront/tools/`. `PackageFS` utilise le même
Expand All @@ -56,7 +58,7 @@ l’autorité du bridge de l’application ; c’est une fonction de développem

- Étendre le protocole pour chaque composant : évité, réutiliser les types du bridge.
- Écraser le handler UI global : remplacé par des abonnements à durée de vie explicite.
- Implémenter TLS ou un registre de paquets C++ dans le cœur : le navigateur fournit HTTPS
- Implémenter un registre de paquets C++ dans le cœur : le navigateur fournit HTTPS
et npm fournit métadonnées et distribution.
- Installer directement dans le répertoire final : rejeté au profit de transactions pour
préserver la version installée en cas d’échec.
Expand Down
Loading
Loading