{"id":"CVE-2022-31140","aliases":["GHSA-5pgm-3j3g-2rc7"],"url":"https://o3.security/vulnerability/CVE-2022-31140","summary":"Valinor error messages leading to potential data exfiltration","details":"```php\n<?php\n\nnamespace My\\App;\n\nuse CuyZ\\Valinor\\Mapper\\MappingError;\nuse CuyZ\\Valinor\\Mapper\\Tree\\Node;\nuse CuyZ\\Valinor\\Mapper\\Tree\\NodeTraverser;\nuse CuyZ\\Valinor\\MapperBuilder;\n\nrequire_once __DIR__ . '/Valinor/vendor/autoload.php';\n\nfinal class Money\n{\n    private function __construct(public readonly string $amount)\n    {\n    }\n\n    public static function fromString(string $money): self\n    {\n        if (1 !== \\preg_match('/^\\d+ [A-Z]{3}$/', $money)) {\n            throw new \\InvalidArgumentException(\\sprintf('Given \"%s\" is not a recognized monetary amount', $money));\n        }\n        \n        return new self($money);\n    }\n}\n\nclass Foo\n{\n    public function __construct(\n        private readonly Money $a,\n        private readonly Money $b,\n        private readonly Money $c,\n    ) {}\n}\n\n$mapper = (new MapperBuilder())\n    ->registerConstructor([Money::class, 'fromString'])\n    ->mapper();\n\ntry {\n    var_dump($mapper->map(Foo::class, [\n        'a' => 'HAHA',\n        'b' => '100 EUR',\n        'c' => 'USD 100'\n    ]));\n} catch (MappingError $e) {\n    $messages = (new NodeTraverser(function (Node $node) {\n        foreach ($node->messages() as $message) {\n            var_dump([\n                '$message',\n                $message->path(),\n                $message->body()\n            ]);\n        }\n        return '';\n    }))->traverse($e->node());\n\n    iterator_to_array($messages);\n}\n```\n\nNow, this is quite innocent: it produces following output:\n\n```\n❯ php value-object-conversion.php\narray(3) {\n  [0]=>\n  string(8) \"$message\"\n  [1]=>\n  string(1) \"a\"\n  [2]=>\n  string(48) \"Given \"HAHA\" is not a recognized monetary amount\"\n}\narray(3) {\n  [0]=>\n  string(8) \"$message\"\n  [1]=>\n  string(1) \"c\"\n  [2]=>\n  string(51) \"Given \"USD 100\" is not a recognized monetary amount\"\n}\n```\n\nThe problem is that nowhere I told valinor that it could use `Throwable#getMessage()`.\n\nThis is a problem with cases where you get:\n\n * an SQL exception showing an SQL snippet\n * a DB connection exception showing DB ip address/username/password\n * a timeout detail / out of memory detail (exploring DDoS possibilities)\n\nThis allows for potential data exfiltration, DDoS, enumeration attacks, etc.","published":"2022-07-11T19:55:09Z","modified":"2026-10-28T02:30:24.557618626Z","cvss":{"score":7.5,"severity":"HIGH","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N"},"epss":null,"cisaKev":null,"exploitsKnown":1,"affectedPackages":[{"ecosystem":"Packagist","name":"cuyz/valinor","fixedVersion":"0.12.0"}],"fix":null,"references":[{"type":"WEB","url":"https://github.com/CuyZ/Valinor/releases/tag/0.12.0"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2022/31xxx/CVE-2022-31140.json"},{"type":"ADVISORY","url":"https://github.com/CuyZ/Valinor/security/advisories/GHSA-5pgm-3j3g-2rc7"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2022-31140"},{"type":"PACKAGE","url":"https://github.com/CuyZ/Valinor"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-10-28T02:30:24.557618626Z"}}