{"answers":{"affected":"2 open source packages ship an affected version, including taylored.","exploited":"There is no known exploitation of GHSA-vh5j-5fhq-9xwg in the wild and no public exploit code.","fix":"Upgrade taylored to 8.1.3 or later.","what":"GHSA-vh5j-5fhq-9xwg is a vulnerability in taylored, published on 27 Jun 2025. Any signed-in user can exploit it over the network, with no action from the victim."},"fix_prompt":"Check this codebase for GHSA-vh5j-5fhq-9xwg and fix it if it is affected.\n\nWhat it is: GHSA-vh5j-5fhq-9xwg is a vulnerability in taylored, published on 27 Jun 2025. Any signed-in user can exploit it over the network, with no action from the victim.\nExploitation: There is no known exploitation of GHSA-vh5j-5fhq-9xwg in the wild and no public exploit code.\n\nAffected packages and fixed versions:\n- taylored (npm): affected all versions; fixed in 8.1.3\n- taylored (npm): affected all versions; fixed in 8.1.3\n\nTask:\n1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.\n2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.\n3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.\n4. Run the tests and summarise what changed and why.\n5. If nothing in the project is affected, say so and change nothing.\n\nReference: https://insights.sbomify.com/GHSA-vh5j-5fhq-9xwg/ (Markdown: https://insights.sbomify.com/GHSA-vh5j-5fhq-9xwg/index.md)","id":"GHSA-vh5j-5fhq-9xwg","markdown":"https://insights.sbomify.com/GHSA-vh5j-5fhq-9xwg/index.md","name":"GHSA-vh5j-5fhq-9xwg","record":{"aliases":[],"analysis":{"component_type":"server_software","fix_type":"patch","impacts":["data_read","security_bypass"],"network_reachable":"yes","non_default_config":false,"product_category":"Taylor patch server","requires_auth":"low_privilege","summary":"An attacker with a valid purchase token can exploit a race condition to replay the token and obtain multiple copies of paid patches.","user_interaction":"not_required","vuln_class":"race_condition"},"analysis_generated_by":"qwen3.8-flash-next","assigner":null,"cpe":[],"cvss":{"score":null,"severity":null,"source":null,"vector":null,"version":null},"cwes":[],"description":"Hi team,\n\nI was looking at the recent fix and you limited the exploitability of race conditions but unfortunately it is still possible to exploit the issue since two requests happening at the exact same time will still go through. You should be able to completely fix the race conditions by leveraging SQLITE write lock and just send one query.\n\n### Summary\nThe /get-patch endpoint processes a purchase in two separate database queries: a SELECT that verifies the token is unused, followed by an UPDATE that marks the token as used. Because SQLite only guards each statement, a malicious actor can issue two requests at the exact same moment and have both SELECT statements succeed before either UPDATE runs.\n\n### Details\n\nThe handler executes (step 1):\n\n```\nSELECT id, token_used_at FROM purchases WHERE patch_id = ? AND purchase_token = ? AND status = 'COMPLETED'\n```\n\nIf token_used_at IS NULL, the request passes the check (step 2): \n```\n        if (row.token_used_at) {\n            return res.status(403).json({ error: \"Purchase token has already been used.\" });\n        }\n```\n\nThe handler finally runs (step 3):\n\n```\nUPDATE purchases SET token_used_at = CURRENT_TIMESTAMP WHERE id = ?\n```\n\nWhen two requests arrive at the same time, they both finish step 1 while the row is still unused. SQLite serializes writers only per statement, so each request believes it has exclusive access. Both decrypt and return the patch, and both UPDATE statements succeed.\n\n### PoC\nTo perform this attack, you need to send two requests at the exact same time. \n\n### Impact\nAn attacker who possesses a valid purchase token can replay it and receive multiple copies of the paid patch, or distribute one copy while still keeping their own. This results in revenue loss and undermines license enforcement.\n\n### Remediation\n\nReplace the read-then-write sequence with a single atomic statement that both validates and consumes the token while SQLite holds the write lock:\n\n```\nconst row = db.prepare(`\n  UPDATE purchases\n     SET token_used_at = CURRENT_TIMESTAMP\n   WHERE patch_id       = ?\n     AND purchase_token = ?\n     AND status         = 'COMPLETED'\n     AND token_used_at IS NULL\n  RETURNING id;\n`).get(patchId, token);\n\nif (!row) return res.status(403).json({ error: 'Invalid or already-used token.' });\n```","ecosystems":["npm"],"exploits":{"exploitdb":null,"first_seen":null,"github_poc":null,"max_poc_stars":null,"metasploit":null,"nuclei":null,"refs":[],"tier":null},"has_fix":true,"headline":"Taylor has race condition in /get-patch that allows purchase token replay","id":"GHSA-vh5j-5fhq-9xwg","indexable":true,"kev":null,"kind":"advisory","links":{"ecosystem":"npm","product":null,"products":[],"type":"race_condition","year":"2025"},"n_packages":2,"n_references":null,"packages":[{"ecosystem":"npm","fixed":["8.1.3"],"introduced":["0"],"last_affected":[],"package":"taylored","purl":null,"source":"GHSA-vh5j-5fhq-9xwg"},{"ecosystem":"npm","fixed":["8.1.3"],"introduced":["0"],"last_affected":[],"package":"taylored","purl":"pkg:npm/taylored","source":"GHSA-vh5j-5fhq-9xwg"}],"products":null,"published":"2025-06-27","related":[],"sources":[{"class":"attribution","licence":"CC BY 4.0","name":"GitHub Advisory Database","prefix":"GHSA"}],"ssvc":{"automatable":null,"exploitation":null,"technical_impact":null},"state":null,"updated":null,"vendors":null},"summary":"An attacker with a valid purchase token can exploit a race condition to replay the token and obtain multiple copies of paid patches.","url":"https://insights.sbomify.com/GHSA-vh5j-5fhq-9xwg/"}