Repository navigation
fix: refuse YAML aliases and accept single-use CAPTCHA tokens only - #476
Merged
Merged
Conversation
YAML: yaml2lambda and yaml2json (and markdown front matter, which goes through yaml2lambda) now parse through SafeYamlParser, which refuses aliases, since a few hundred bytes of aliases referring to aliases expand into gigabytes, and refuses documents nested deeper than 256 levels, since a stack overflow kills the process. CAPTCHA: magic.auth.captcha-verify accepts challenge-based tokens only. The age-based mode accepted the same token any number of times within its window, so it is removed along with its client library, magic-captcha.js. magic-captcha-challenge.js has the same API. Bumps the version to v24.5.5. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The deserializer wrapped the alias error thrown from inside its parser in a YamlException, so callers saw "Exception during deserialization". Aliases are now refused by YamlGuard in a separate scan before deserializing, giving a plain "YAML aliases are not supported" error. The depth limit is dropped, since YamlDotNet's deserializer already refuses runaway nesting itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



YAML
yaml2lambdaandyaml2jsonnow refuse aliases. Markdown front matter goes throughyaml2lambda, so it is covered too. A few hundred bytes of aliases that refer to other aliases expand into gigabytes ("billion laughs"), which caused the OutOfMemoryException in the external review. Capping the number of aliases doesn't bound the expansion, and data YAML has no need for aliases, so they are refused outright. Anchors that nothing refers to are still accepted.YamlGuard.Ensurechecks for aliases in a separate scan before deserializing, the same wayHtmlDepth.Ensurechecks HTML. It can't be done inside the deserializer, because YamlDotNet wraps anything its parser throws in a generic "Exception during deserialization". Deep nesting needs no guard of ours: YamlDotNet's deserializer already throwsMaximumRecursionLevelReachedException, which can be caught.XML needed no change:
xml2lambdaalready prohibits DTDs.CAPTCHA
magic.auth.captcha-verifynow accepts challenge-based tokens only:c_challenge issued by/magic/system/misc/challenge, and the challenge is removed from the cache on first use. The[age]argument is gone from the slot and from themcaptchaworkflow action.magic-captcha.jsand its endpoint are removed.magic-captcha-challenge.js, which the chat widget already uses, has the samemcaptcha.token(callback, workload)API.Checked on a local backend: a fresh token is accepted, the same token replayed is refused, an age-style token is refused,
magic-captcha.jsreturns 404 andmagic-captcha-challenge.jsreturns 200.Other
JsonTests.cs: aliases are refused in both slots, and an unused anchor is still accepted.🤖 Generated with Claude Code