Common Weakness Enumeration

CWE-367

Allowed

Time-of-check Time-of-use (TOCTOU) Race Condition

Abstraction: Base · Status: Incomplete

The product checks the state of a resource before using that resource, but the resource's state can change between the check and the use in a way that invalidates the results of the check.

1063 vulnerabilities reference this CWE, most recent first.

GHSA-3CVR-9V2W-RHHQ

Vulnerability from github – Published: 2022-05-24 17:32 – Updated: 2022-05-24 17:32
VLAI
Details

This issue was addressed with improved checks. This issue is fixed in macOS Catalina 10.15.6. A local user may be able to load unsigned kernel extensions.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2020-9939"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-367"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2020-10-22T19:15:00Z",
    "severity": "MODERATE"
  },
  "details": "This issue was addressed with improved checks. This issue is fixed in macOS Catalina 10.15.6. A local user may be able to load unsigned kernel extensions.",
  "id": "GHSA-3cvr-9v2w-rhhq",
  "modified": "2022-05-24T17:32:09Z",
  "published": "2022-05-24T17:32:09Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2020-9939"
    },
    {
      "type": "WEB",
      "url": "https://support.apple.com/kb/HT211289"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

GHSA-3F72-RQQJ-2FM8

Vulnerability from github – Published: 2022-11-23 03:30 – Updated: 2022-11-27 06:30
VLAI
Details

An Arm product family through 2022-06-29 has a TOCTOU Race Condition that allows non-privileged user to make improper GPU processing operations to gain access to already freed memory.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2022-34830"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-367"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2022-11-23T03:15:00Z",
    "severity": "HIGH"
  },
  "details": "An Arm product family through 2022-06-29 has a TOCTOU Race Condition that allows non-privileged user to make improper GPU processing operations to gain access to already freed memory.",
  "id": "GHSA-3f72-rqqj-2fm8",
  "modified": "2022-11-27T06:30:23Z",
  "published": "2022-11-23T03:30:22Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2022-34830"
    },
    {
      "type": "WEB",
      "url": "https://developer.arm.com/Arm%20Security%20Center/Mali%20GPU%20Driver%20Vulnerabilities"
    },
    {
      "type": "WEB",
      "url": "https://developer.arm.com/support/arm-security-updates"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-3G2W-RHVJ-J46G

Vulnerability from github – Published: 2023-10-27 21:30 – Updated: 2023-11-07 21:30
VLAI
Details

A Time of Check Time of Use (TOCTOU) vulnerability was reported in the Lenovo Vantage SystemUpdate Plugin version 2.0.0.212 and earlier that could allow a local attacker to delete arbitrary files.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2022-3700"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-367"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2023-10-27T20:15:08Z",
    "severity": "MODERATE"
  },
  "details": "A Time of Check Time of Use (TOCTOU) vulnerability was reported in the Lenovo Vantage SystemUpdate Plugin version 2.0.0.212 and earlier that could allow a local attacker to delete arbitrary files.",
  "id": "GHSA-3g2w-rhvj-j46g",
  "modified": "2023-11-07T21:30:23Z",
  "published": "2023-10-27T21:30:23Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2022-3700"
    },
    {
      "type": "WEB",
      "url": "https://support.lenovo.com/us/en/product_security/LEN-94532"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:L",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-3GCX-WJR4-JV32

Vulnerability from github – Published: 2023-06-28 12:30 – Updated: 2023-12-04 15:31
VLAI
Details

A time-of-check to time-of-use issue exists in io_uring subsystem's IORING_OP_CLOSE operation in the Linux kernel's versions 5.6 - 5.11 (inclusive), which allows a local user to elevate their privileges to root. Introduced in b5dba59e0cf7e2cc4d3b3b1ac5fe81ddf21959eb, patched in 9eac1904d3364254d622bf2c771c4f85cd435fc2, backported to stable in 788d0824269bef539fe31a785b1517882eafed93.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2023-1295"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-367"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2023-06-28T12:15:09Z",
    "severity": "HIGH"
  },
  "details": "A time-of-check to time-of-use issue exists in io_uring subsystem\u0027s IORING_OP_CLOSE operation in the Linux kernel\u0027s versions 5.6 - 5.11 (inclusive), which allows a local user to elevate their privileges to root. Introduced in b5dba59e0cf7e2cc4d3b3b1ac5fe81ddf21959eb, patched in 9eac1904d3364254d622bf2c771c4f85cd435fc2, backported to stable in 788d0824269bef539fe31a785b1517882eafed93.",
  "id": "GHSA-3gcx-wjr4-jv32",
  "modified": "2023-12-04T15:31:54Z",
  "published": "2023-06-28T12:30:16Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2023-1295"
    },
    {
      "type": "WEB",
      "url": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=788d0824269bef539fe31a785b1517882eafed93"
    },
    {
      "type": "WEB",
      "url": "https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9eac1904d3364254d622bf2c771c4f85cd435fc2"
    },
    {
      "type": "WEB",
      "url": "https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b5dba59e0cf7e2cc4d3b3b1ac5fe81ddf21959eb"
    },
    {
      "type": "WEB",
      "url": "https://kernel.dance/788d0824269bef539fe31a785b1517882eafed93"
    },
    {
      "type": "WEB",
      "url": "https://kernel.dance/9eac1904d3364254d622bf2c771c4f85cd435fc2"
    },
    {
      "type": "WEB",
      "url": "https://security.netapp.com/advisory/ntap-20230731-0006"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-3GXJ-93JF-H822

Vulnerability from github – Published: 2022-05-13 01:43 – Updated: 2022-05-13 01:43
VLAI
Details

An ability to process crash dumps under root privileges and inappropriate symlinks handling could lead to a local privilege escalation in Crash Reporting in Google Chrome on Chrome OS prior to 61.0.3163.113 allowed a local attacker to perform privilege escalation via a crafted HTML page.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2017-15404"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-367"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2019-01-09T19:29:00Z",
    "severity": "HIGH"
  },
  "details": "An ability to process crash dumps under root privileges and inappropriate symlinks handling could lead to a local privilege escalation in Crash Reporting in Google Chrome on Chrome OS prior to 61.0.3163.113 allowed a local attacker to perform privilege escalation via a crafted HTML page.",
  "id": "GHSA-3gxj-93jf-h822",
  "modified": "2022-05-13T01:43:45Z",
  "published": "2022-05-13T01:43:45Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2017-15404"
    },
    {
      "type": "WEB",
      "url": "https://chromereleases.googleblog.com/2017/10/stable-channel-updates-for-chrome-os.html"
    },
    {
      "type": "WEB",
      "url": "https://crbug.com/766275"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.0/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-3JJ9-9269-99M2

Vulnerability from github – Published: 2024-08-06 15:30 – Updated: 2024-08-12 18:30
VLAI
Details

Calling PK11_Encrypt() in NSS using CKM_CHACHA20 and the same buffer for input and output can result in plaintext on an Intel Sandy Bridge processor. In Firefox this only affects the QUIC header protection feature when the connection is using the ChaCha20-Poly1305 cipher suite. The most likely outcome is connection failure, but if the connection persists despite the high packet loss it could be possible for a network observer to identify packets as coming from the same source despite a network path change. This vulnerability affects Firefox < 129, Firefox ESR < 115.14, and Firefox ESR < 128.1.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2024-7531"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-367"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2024-08-06T13:15:57Z",
    "severity": "MODERATE"
  },
  "details": "Calling `PK11_Encrypt()` in NSS using CKM_CHACHA20 and the same buffer for input and output can result in plaintext on an Intel Sandy Bridge processor. In Firefox this only affects the QUIC header protection feature when the connection is using the ChaCha20-Poly1305 cipher suite. The most likely outcome is connection failure, but if the connection persists despite the high packet loss it could be possible for a network observer to identify packets as coming from the same source despite a network path change. This vulnerability affects Firefox \u003c 129, Firefox ESR \u003c 115.14, and Firefox ESR \u003c 128.1.",
  "id": "GHSA-3jj9-9269-99m2",
  "modified": "2024-08-12T18:30:46Z",
  "published": "2024-08-06T15:30:54Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2024-7531"
    },
    {
      "type": "WEB",
      "url": "https://bugzilla.mozilla.org/show_bug.cgi?id=1905691"
    },
    {
      "type": "WEB",
      "url": "https://www.mozilla.org/security/advisories/mfsa2024-33"
    },
    {
      "type": "WEB",
      "url": "https://www.mozilla.org/security/advisories/mfsa2024-34"
    },
    {
      "type": "WEB",
      "url": "https://www.mozilla.org/security/advisories/mfsa2024-35"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-3MG2-Q757-F3M2

Vulnerability from github – Published: 2022-05-12 00:01 – Updated: 2022-05-20 00:00
VLAI
Details

TOCTOU (time-of-check to time-of-use) issue in the System Management Unit (SMU) may result in a DMA (Direct Memory Access) to invalid DRAM address that could result in denial of service.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2021-26347"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-367"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2022-05-11T17:15:00Z",
    "severity": "MODERATE"
  },
  "details": "TOCTOU (time-of-check to time-of-use) issue in the System Management Unit (SMU) may result in a DMA (Direct Memory Access) to invalid DRAM address that could result in denial of service.",
  "id": "GHSA-3mg2-q757-f3m2",
  "modified": "2022-05-20T00:00:25Z",
  "published": "2022-05-12T00:01:27Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2021-26347"
    },
    {
      "type": "WEB",
      "url": "https://www.amd.com/en/corporate/product-security/bulletin/AMD-SB-1031"
    },
    {
      "type": "WEB",
      "url": "https://www.amd.com/en/corporate/product-security/bulletin/amd-sb-1028"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:H",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-3P2X-HJXJ-C7RV

Vulnerability from github – Published: 2026-03-21 03:31 – Updated: 2026-03-24 19:04
VLAI
Summary
Duplicate Advisory: OpenClaw's system.run approval TOCTOU via mutable symlink cwd target on node host
Details

Duplicate Advisory

This advisory has been withdrawn because it is a duplicate of GHSA-mwcg-wfq3-4gjc. This link is maintained to preserve external references.

Original Description

OpenClaw versions prior to 2026.2.25 contain a time-of-check-time-of-use vulnerability in approval-bound system.run execution where the cwd parameter is validated at approval time but resolved at execution time. Attackers can retarget a symlinked cwd between approval and execution to bypass command execution restrictions and execute arbitrary commands on node hosts.

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "npm",
        "name": "openclaw"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "last_affected": "2026.2.24"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [],
  "database_specific": {
    "cwe_ids": [
      "CWE-367"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-03-24T19:04:22Z",
    "nvd_published_at": "2026-03-21T01:17:06Z",
    "severity": "MODERATE"
  },
  "details": "## Duplicate Advisory\n\nThis advisory has been withdrawn because it is a duplicate of GHSA-mwcg-wfq3-4gjc. This link is maintained to preserve external references.\n\n## Original Description\nOpenClaw versions prior to 2026.2.25 contain a time-of-check-time-of-use vulnerability in approval-bound system.run execution where the cwd parameter is validated at approval time but resolved at execution time. Attackers can retarget a symlinked cwd between approval and execution to bypass command execution restrictions and execute arbitrary commands on node hosts.",
  "id": "GHSA-3p2x-hjxj-c7rv",
  "modified": "2026-03-24T19:04:22Z",
  "published": "2026-03-21T03:31:13Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/openclaw/openclaw/security/advisories/GHSA-mwcg-wfq3-4gjc"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-32043"
    },
    {
      "type": "WEB",
      "url": "https://github.com/openclaw/openclaw/commit/f789f880c934caa8be25b38832f27f90f37903db"
    },
    {
      "type": "WEB",
      "url": "https://www.vulncheck.com/advisories/openclaw-time-of-check-time-of-use-via-mutable-symlink-in-system-run-cwd-parameter"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:L/I:H/A:H",
      "type": "CVSS_V3"
    },
    {
      "score": "CVSS:4.0/AV:L/AC:H/AT:N/PR:L/UI:N/VC:L/VI:H/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X",
      "type": "CVSS_V4"
    }
  ],
  "summary": "Duplicate Advisory: OpenClaw\u0027s system.run approval TOCTOU via mutable symlink cwd target on node host",
  "withdrawn": "2026-03-24T19:04:22Z"
}

GHSA-3PHX-V48R-RMWC

Vulnerability from github – Published: 2024-08-13 18:31 – Updated: 2025-03-18 21:31
VLAI
Details

A TOCTOU (Time-Of-Check-Time-Of-Use) in SMM may allow an attacker with ring0 privileges and access to the BIOS menu or UEFI shell to modify the communications buffer potentially resulting in arbitrary code execution.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2023-20578"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-367"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2024-08-13T17:15:19Z",
    "severity": "HIGH"
  },
  "details": "A TOCTOU (Time-Of-Check-Time-Of-Use) in SMM may allow\nan attacker with ring0 privileges and access to the\nBIOS menu or UEFI shell to modify the communications buffer\u00a0potentially\nresulting in arbitrary code execution.",
  "id": "GHSA-3phx-v48r-rmwc",
  "modified": "2025-03-18T21:31:48Z",
  "published": "2024-08-13T18:31:15Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2023-20578"
    },
    {
      "type": "WEB",
      "url": "https://www.amd.com/en/resources/product-security/bulletin/amd-sb-3003.html"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:C/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-3PQC-836W-JGR7

Vulnerability from github – Published: 2026-01-13 21:53 – Updated: 2026-01-21 16:17
VLAI
Summary
Outray cli is vulnerable to race conditions in tunnels creation
Details

Summary

A TOCTOU race condition vulnerability allows a user to exceed the set number of active tunnels in their subscription plan.

Details

Affected conponent: apps/web/src/routes/api/tunnel/register.ts - /tunnel/register endpoint code-:

// Check if tunnel already exists in database
          const [existingTunnel] = await db
            .select()
            .from(tunnels)
            .where(eq(tunnels.url, tunnelUrl));

          const isReconnection = !!existingTunnel;

          console.log(
            `[TUNNEL LIMIT CHECK] Org: ${organizationId}, Tunnel: ${tunnelId}`,
          );
          console.log(
            `[TUNNEL LIMIT CHECK] Is Reconnection: ${isReconnection}`,
          );
          console.log(
            `[TUNNEL LIMIT CHECK] Plan: ${currentPlan}, Limit: ${tunnelLimit}`,
          );

          // Check limits only for NEW tunnels (not reconnections)
          if (!isReconnection) {
            // Count active tunnels from Redis SET
            const activeCount = await redis.scard(setKey);
            console.log(
              `[TUNNEL LIMIT CHECK] Active count in Redis: ${activeCount}`,
            );

            // The current tunnel is NOT yet in the online_tunnels set (added after successful registration)
            // So we check if activeCount >= limit (not >)
            if (activeCount >= tunnelLimit) {
              console.log(
                `[TUNNEL LIMIT CHECK] REJECTED - ${activeCount} >= ${tunnelLimit}`,
              );
              return json(
                {
                  error: `Tunnel limit reached. The ${currentPlan} plan allows ${tunnelLimit} active tunnel${tunnelLimit > 1 ? "s" : ""}.`,
                },
                { status: 403 },
              );
            }
            console.log(
              `[TUNNEL LIMIT CHECK] ALLOWED - ${activeCount} < ${tunnelLimit}`,
            );
          } else {
            console.log(`[TUNNEL LIMIT CHECK] SKIPPED - Reconnection detected`);
          }

          if (existingTunnel) {
            // Tunnel with this URL already exists, update lastSeenAt
            await db
              .update(tunnels)
              .set({ lastSeenAt: new Date() })
              .where(eq(tunnels.id, existingTunnel.id));

            return json({
              success: true,
              tunnelId: existingTunnel.id,
            });
          }

          // Create new tunnel record
          const tunnelRecord = {
            id: randomUUID(),
            url: tunnelUrl,
            userId,
            organizationId,
            name: name || null,
            protocol,
            remotePort: remotePort || null,
            lastSeenAt: new Date(),
            createdAt: new Date(),
            updatedAt: new Date(),
          };

          await db.insert(tunnels).values(tunnelRecord);

          return json({ success: true, tunnelId: tunnelRecord.id });
        } catch (error) {
          console.error("Tunnel registration error:", error);
          return json({ error: "Internal server error" }, { status: 500 });
        }
  • It checks if the tunnel exists in the database.
// Check if tunnel already exists in database
          const [existingTunnel] = await db
            .select()
            .from(tunnels)
            .where(eq(tunnels.url, tunnelUrl));

          const isReconnection = !!existingTunnel;
  • Limit is checked here-:
// Check limits only for NEW tunnels (not reconnections)

if (!isReconnection) {

// Count active tunnels from Redis SET

const activeCount = await redis.scard(setKey);

console.log(

`[TUNNEL LIMIT CHECK] Active count in Redis: ${activeCount}`,

);
  • Redis is checked for existing tunnel to check for reconnection.
// Check limits only for NEW tunnels (not reconnections)
          if (!isReconnection) {
            // Count active tunnels from Redis SET
            const activeCount = await redis.scard(setKey);
            console.log(
              `[TUNNEL LIMIT CHECK] Active count in Redis: ${activeCount}`,
            );
  • If the tunnel limit is exceeded, it pops up the tunnel limit error.
if (activeCount >= tunnelLimit) {
              console.log(
                `[TUNNEL LIMIT CHECK] REJECTED - ${activeCount} >= ${tunnelLimit}`,
              );
              return json(
                {
                  error: `Tunnel limit reached. The ${currentPlan} plan allows ${tunnelLimit} active tunnel${tunnelLimit > 1 ? "s" : ""}.`,
                },
                { status: 403 },
              );
  • If the limit is not exceeded, it triggers a the Insert Statement without locking transactions from other request
await db.insert(tunnels).values(tunnelRecord);
  • If parallel requests are made by the wshandler in /outray/outray-main/apps/tunnel/src/core/WSHandler.ts from the command line app. A request can work on a non updated row because the insert row has not been triggered allowing the user to bypass the limit. It is much explained in the proof of concept. The key takeaway is db transactions should remain locked.

PoC

Using this simple bash script, the outray binary will be run at the same time in one tmux window, demonstrating the race condition and opening 4 tunnels.

#!/usr/bin/env bash

# POC for Outray Tunnel Race condition
SESSION="outray-race"
PORTS=(8090 4000 5000 6000)

# Create new detached tmux session
tmux new-session -d -s "$SESSION" "echo '[*] outray race session started'; bash"

# Split the panes and run outray
for i in "${!PORTS[@]}"; do
  port="${PORTS[$i]}"

  if [ "$i" -ne 0 ]; then
    tmux split-window -t "$SESSION" -h
    tmux select-layout -t "$SESSION" tiled
  fi

  tmux send-keys -t "$SESSION" "echo '[*] Running outray on port $port'; outray $port" C-m
done

tmux set-window-option -t "$SESSION" synchronize-panes off

echo "[+] tmux session '$SESSION' created"
echo "[+] Attach with: tmux attach -t $SESSION"

Running this

seeker@instance-20260106-20011$ bash kay.sh
[+] tmux session 'outray-race' created
[+] Attach with: tmux attach -t outray-race

seeker@instance-20260106-20011$ tmux attach -t outray-race

image

image

Impact

By exploiting this TOCTOU race condition in the affected component, the intended limit is bypassed and server resources is used with no extra billing charges on the user.

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "npm",
        "name": "outray"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "0.1.5"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2026-22820"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-367"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-01-13T21:53:44Z",
    "nvd_published_at": "2026-01-14T15:16:05Z",
    "severity": "MODERATE"
  },
  "details": "### Summary\n\nA TOCTOU race condition vulnerability allows a user to exceed the set number of active tunnels in their subscription plan.\n\n### Details\n\nAffected conponent: `apps/web/src/routes/api/tunnel/register.ts`\n- `/tunnel/register` endpoint code-:\n\n```ts\n// Check if tunnel already exists in database\n          const [existingTunnel] = await db\n            .select()\n            .from(tunnels)\n            .where(eq(tunnels.url, tunnelUrl));\n\n          const isReconnection = !!existingTunnel;\n\n          console.log(\n            `[TUNNEL LIMIT CHECK] Org: ${organizationId}, Tunnel: ${tunnelId}`,\n          );\n          console.log(\n            `[TUNNEL LIMIT CHECK] Is Reconnection: ${isReconnection}`,\n          );\n          console.log(\n            `[TUNNEL LIMIT CHECK] Plan: ${currentPlan}, Limit: ${tunnelLimit}`,\n          );\n\n          // Check limits only for NEW tunnels (not reconnections)\n          if (!isReconnection) {\n            // Count active tunnels from Redis SET\n            const activeCount = await redis.scard(setKey);\n            console.log(\n              `[TUNNEL LIMIT CHECK] Active count in Redis: ${activeCount}`,\n            );\n\n            // The current tunnel is NOT yet in the online_tunnels set (added after successful registration)\n            // So we check if activeCount \u003e= limit (not \u003e)\n            if (activeCount \u003e= tunnelLimit) {\n              console.log(\n                `[TUNNEL LIMIT CHECK] REJECTED - ${activeCount} \u003e= ${tunnelLimit}`,\n              );\n              return json(\n                {\n                  error: `Tunnel limit reached. The ${currentPlan} plan allows ${tunnelLimit} active tunnel${tunnelLimit \u003e 1 ? \"s\" : \"\"}.`,\n                },\n                { status: 403 },\n              );\n            }\n            console.log(\n              `[TUNNEL LIMIT CHECK] ALLOWED - ${activeCount} \u003c ${tunnelLimit}`,\n            );\n          } else {\n            console.log(`[TUNNEL LIMIT CHECK] SKIPPED - Reconnection detected`);\n          }\n\n          if (existingTunnel) {\n            // Tunnel with this URL already exists, update lastSeenAt\n            await db\n              .update(tunnels)\n              .set({ lastSeenAt: new Date() })\n              .where(eq(tunnels.id, existingTunnel.id));\n\n            return json({\n              success: true,\n              tunnelId: existingTunnel.id,\n            });\n          }\n\n          // Create new tunnel record\n          const tunnelRecord = {\n            id: randomUUID(),\n            url: tunnelUrl,\n            userId,\n            organizationId,\n            name: name || null,\n            protocol,\n            remotePort: remotePort || null,\n            lastSeenAt: new Date(),\n            createdAt: new Date(),\n            updatedAt: new Date(),\n          };\n\n          await db.insert(tunnels).values(tunnelRecord);\n\n          return json({ success: true, tunnelId: tunnelRecord.id });\n        } catch (error) {\n          console.error(\"Tunnel registration error:\", error);\n          return json({ error: \"Internal server error\" }, { status: 500 });\n        }\n```\n- It checks if the tunnel exists in the database.\n```ts\n// Check if tunnel already exists in database\n          const [existingTunnel] = await db\n            .select()\n            .from(tunnels)\n            .where(eq(tunnels.url, tunnelUrl));\n\n          const isReconnection = !!existingTunnel;\n```\n\n- Limit is checked here-:\n```ts\n// Check limits only for NEW tunnels (not reconnections)\n\nif (!isReconnection) {\n\n// Count active tunnels from Redis SET\n\nconst activeCount = await redis.scard(setKey);\n\nconsole.log(\n\n`[TUNNEL LIMIT CHECK] Active count in Redis: ${activeCount}`,\n\n);\n```\n- Redis is checked for existing tunnel to check for reconnection.\n```ts\n// Check limits only for NEW tunnels (not reconnections)\n          if (!isReconnection) {\n            // Count active tunnels from Redis SET\n            const activeCount = await redis.scard(setKey);\n            console.log(\n              `[TUNNEL LIMIT CHECK] Active count in Redis: ${activeCount}`,\n            );\n```\n\n- If the tunnel limit is exceeded, it pops up the tunnel limit error.\n\n```ts\nif (activeCount \u003e= tunnelLimit) {\n              console.log(\n                `[TUNNEL LIMIT CHECK] REJECTED - ${activeCount} \u003e= ${tunnelLimit}`,\n              );\n              return json(\n                {\n                  error: `Tunnel limit reached. The ${currentPlan} plan allows ${tunnelLimit} active tunnel${tunnelLimit \u003e 1 ? \"s\" : \"\"}.`,\n                },\n                { status: 403 },\n              );\n```\n- If the limit is not exceeded, it triggers a the `Insert` Statement without locking transactions from other request\n\n```ts\nawait db.insert(tunnels).values(tunnelRecord);\n```\n- If parallel requests are made by the `wshandler` in `/outray/outray-main/apps/tunnel/src/core/WSHandler.ts` from the command line app. A request can work on a non updated  row  because the `insert` row has not been triggered allowing the user to bypass the limit. It is much explained in the proof of concept. The key takeaway is db transactions should remain locked.\n\n### PoC\n\nUsing this simple bash script, the `outray` binary will be run at the same time in one `tmux` window, demonstrating the race condition and opening 4 tunnels.\n\n```bash\n#!/usr/bin/env bash\n\n# POC for Outray Tunnel Race condition\nSESSION=\"outray-race\"\nPORTS=(8090 4000 5000 6000)\n\n# Create new detached tmux session\ntmux new-session -d -s \"$SESSION\" \"echo \u0027[*] outray race session started\u0027; bash\"\n\n# Split the panes and run outray\nfor i in \"${!PORTS[@]}\"; do\n  port=\"${PORTS[$i]}\"\n\n  if [ \"$i\" -ne 0 ]; then\n    tmux split-window -t \"$SESSION\" -h\n    tmux select-layout -t \"$SESSION\" tiled\n  fi\n\n  tmux send-keys -t \"$SESSION\" \"echo \u0027[*] Running outray on port $port\u0027; outray $port\" C-m\ndone\n\ntmux set-window-option -t \"$SESSION\" synchronize-panes off\n\necho \"[+] tmux session \u0027$SESSION\u0027 created\"\necho \"[+] Attach with: tmux attach -t $SESSION\"\n\n```\n\nRunning this\n\n```\nseeker@instance-20260106-20011$ bash kay.sh\n[+] tmux session \u0027outray-race\u0027 created\n[+] Attach with: tmux attach -t outray-race\n\nseeker@instance-20260106-20011$ tmux attach -t outray-race\n```\n\n\u003cimg width=\"1909\" height=\"1021\" alt=\"image\" src=\"https://github.com/user-attachments/assets/c234cc94-fc25-4542-abdf-815332493a85\" /\u003e\n\n\n\u003cimg width=\"1907\" height=\"936\" alt=\"image\" src=\"https://github.com/user-attachments/assets/1c302d7f-1ca6-46af-ab72-60fd01cdfded\" /\u003e\n\n### Impact\n\nBy exploiting this TOCTOU race condition in the affected component, the intended limit is bypassed and server resources is used with no extra billing charges on the user.",
  "id": "GHSA-3pqc-836w-jgr7",
  "modified": "2026-01-21T16:17:07Z",
  "published": "2026-01-13T21:53:44Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/akinloluwami/outray/security/advisories/GHSA-3pqc-836w-jgr7"
    },
    {
      "type": "WEB",
      "url": "https://github.com/outray-tunnel/outray/security/advisories/GHSA-3pqc-836w-jgr7"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-22820"
    },
    {
      "type": "WEB",
      "url": "https://github.com/outray-tunnel/outray/commit/08c61495761349e7fd2965229c3faa8d7b1c1581"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/akinloluwami/outray"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:N",
      "type": "CVSS_V3"
    },
    {
      "score": "CVSS:4.0/AV:N/AC:H/AT:N/PR:N/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N",
      "type": "CVSS_V4"
    }
  ],
  "summary": "Outray cli is vulnerable to race conditions in tunnels creation"
}

Mitigation
Implementation

The most basic advice for TOCTOU vulnerabilities is to not perform a check before the use. This does not resolve the underlying issue of the execution of a function on a resource whose state and identity cannot be assured, but it does help to limit the false sense of security given by the check.

Mitigation
Implementation

When the file being altered is owned by the current user and group, set the effective gid and uid to that of the current user and group when executing this statement.

Mitigation
Architecture and Design

Limit the interleaving of operations on files from multiple processes.

Mitigation
Implementation Architecture and Design

If you cannot perform operations atomically and you must share access to the resource between multiple processes or threads, then try to limit the amount of time (CPU cycles) between the check and use of the resource. This will not fix the problem, but it could make it more difficult for an attack to succeed.

Mitigation
Implementation

Recheck the resource after the use call to verify that the action was taken appropriately.

Mitigation
Architecture and Design

Ensure that some environmental locking mechanism can be used to protect resources effectively.

Mitigation
Implementation

Ensure that locking occurs before the check, as opposed to afterwards, such that the resource, as checked, is the same as it is when in use.

CAPEC-27: Leveraging Race Conditions via Symbolic Links

This attack leverages the use of symbolic links (Symlinks) in order to write to sensitive files. An attacker can create a Symlink link to a target file not otherwise accessible to them. When the privileged program tries to create a temporary file with the same name as the Symlink link, it will actually write to the target file pointed to by the attackers' Symlink link. If the attacker can insert malicious content in the temporary file they will be writing to the sensitive file by using the Symlink. The race occurs because the system checks if the temporary file exists, then creates the file. The attacker would typically create the Symlink during the interval between the check and the creation of the temporary file.

CAPEC-29: Leveraging Time-of-Check and Time-of-Use (TOCTOU) Race Conditions

This attack targets a race condition occurring between the time of check (state) for a resource and the time of use of a resource. A typical example is file access. The adversary can leverage a file access race condition by "running the race", meaning that they would modify the resource between the first time the target program accesses the file and the time the target program uses the file. During that period of time, the adversary could replace or modify the file, causing the application to behave unexpectedly.