Background
WeTTY (Web + TTY) is an open-source terminal in the browser. A Node.js server serves a web page that shows a terminal, and relays keystrokes over a Socket.IO connection to either a local shell or an SSH session on another machine. It is commonly used to give people shell access to a server through a web page without installing an SSH client.
For monitoring, WeTTY records HTTP statistics with a Prometheus client library. Prometheus is a popular monitoring system. An application keeps counters and histograms in memory, and a Prometheus server periodically scrapes them from a /metrics endpoint. Each metric can carry labels, such as the request path, and the library keeps a separate time series in memory for every unique combination of label values.
Terms used below:
- Cardinality is the number of distinct label combinations, which is also the number of series held in memory.
- Middleware is code that runs on every incoming request before the application’s own handlers.
- Denial of service (DoS) is making a service slow or unavailable, here by running it out of memory.
Summary
Unauthenticated requests to continually changing paths can create metric series that remain in memory for the lifetime of the process. Incomplete path normalization lets a client grow the registry without opening a terminal or passing SSH authentication.
The affected counter and histograms run on ordinary application traffic. The metrics endpoint is therefore not the only entry point. Hiding that endpoint does not stop other requests from adding labels. The resource failure is the number of distinct retained series, not the size of an individual response.
How the Vulnerability Works
Metric labels are supposed to come from a small, fixed set, such as GET / and GET /socket.io. A well-known way to break this is to put attacker-controlled text into a label. Every new value creates a new series that the process keeps for as long as it runs. There is no expiry and no upper limit.
WeTTY’s middleware builds the path label with a function called normalizePath. It tries to collapse variable parts of a URL, but it only recognizes numbers. Text segments pass through unchanged:
GET /wetty/ssh/alice -> label path="/wetty/ssh/alice"
GET /wetty/ssh/bob -> label path="/wetty/ssh/bob"
GET /wetty/ssh/x9f3k2 -> label path="/wetty/ssh/x9f3k2" (new series every time)The paths do not need to be real. A request for a page that does not exist still passes through the middleware before any handler decides to return a 404, so each made-up path creates a new in-memory series. Sustained requests with changing strings make the registry grow without a bound, which can eventually exhaust the Node.js process’s memory. The advisory does not claim a specific number of requests or bytes per request that would be needed.
Two details make this worse. The request does not need a login, because the middleware runs before the terminal’s SSH authentication. And protecting the /metrics endpoint does not help. That endpoint only reads the data. The data is created by every other request.
The fix is a standard one for this class (CWE-770, allocation of resources without limits). Map each request to a fixed set of labels, so the number of series stays bounded no matter what an attacker sends. WeTTY 4.0.0 does this with five fixed route families, a short list of HTTP methods plus an OTHER bucket, and four status groups.
Prerequisites
The attacker needs network access to the HTTP application port. Paths can differ in usernames, asset names or arbitrary text. No successful login, terminal session or permission to scrape metrics is required to exercise the middleware.
This matters for deployments that authenticate only after a request reaches WeTTY. The middleware runs before terminal authentication, so SSH access controls do not bound how many label values an HTTP client can create.
Attack Path
- STARTUnauthenticated HTTP client
- STEP 01Send requests with changing textual paths
Each path can introduce a label value even when no terminal opens.
- STEP 02Metrics retain a new series for each path
MITIGATION Map requests to a fixed set of route labels
- STEP 03Repeat requests to grow the registry
MITIGATION Restrict application access and rate-limit traffic
- STEP 04Memory pressure disrupts the service
Root Cause
The middleware derives labels from the request URL through normalizePath. The affected normalization collapses numeric segments but leaves arbitrary textual segments distinct. Repeating a path reuses an existing series, while changing its text can create another.
The Prometheus client retains label combinations in a process-wide registry. The path handling supplies no fixed vocabulary, cap or eviction policy. Counters and histograms can therefore accumulate state controlled by unauthenticated request input.
A path does not need to identify a valid resource to create a label. The request has already reached the observation middleware before a later handler can reject it. Access control on the scrape endpoint also runs too late to prevent this state from being created.
Validation
The proof of concept used WeTTY 3.3.5 (revision 15f2bdb4) in a local deployment. It compared repeated requests to one path with requests to distinct paths, then compared the number of series in the registry.
| Request pattern | Expected resource behavior | Recorded result |
|---|---|---|
| Repeated identical path | Reuse the existing label set | One added series |
| Three hundred unique paths | Reuse bounded route families | Three hundred added series |
| Requests without a terminal login | Bound resources before authentication | Metrics were still recorded |
This writeup does not give a per-request memory cost or a request count that guarantees exhaustion. The published advisory also limits its claim to the unbounded number of retained series.
Impact
Sustained traffic can consume process memory until the terminal service slows down or terminates. A completed or rejected request can leave behind state that affects later users because the registry lives in the same process.
The finding establishes an availability issue, not terminal access or command execution. Memory use depends on the runtime, metric types and workload. Rate limiting can slow growth, but it does not make an unbounded label space finite.
Remediation
Upgrade to 4.0.0 or later. The fix replaces request-derived labels with bounded route families, methods and status groups across all four HTTP metrics. Scrapes are excluded from observation. PR #698 contains the changes.
The release also requires an explicit trusted browser origin, including for localhost deployments. Follow the linked migration documentation when upgrading. Until then, restrict application access and request rates. Protecting only /metrics is insufficient because ordinary requests still reach the middleware.
Regression checks should send many distinct usernames and unknown paths and confirm that series counts stop increasing once the fixed label families exist.
References
- Project repository (https://github.com/butlerx/wetty)
- GitHub security advisory (https://github.com/butlerx/wetty/security/advisories/GHSA-923j-vq86-6fgf)
- Security fixes (https://github.com/butlerx/wetty/pull/698)
- Fixed release (https://github.com/butlerx/wetty/releases/tag/v4.0.0)
- Metrics configuration (https://github.com/butlerx/wetty/blob/v4.0.0/docs/flags.md#prometheus-metrics)