{"id":"GHSA-5pgm-3j3g-2rc7","summary":"Valinor error messages leading to potential data exfiltration before v0.12.0","details":"```php\n\u003c?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    -\u003eregisterConstructor([Money::class, 'fromString'])\n    -\u003emapper();\n\ntry {\n    var_dump($mapper-\u003emap(Foo::class, [\n        'a' =\u003e 'HAHA',\n        'b' =\u003e '100 EUR',\n        'c' =\u003e 'USD 100'\n    ]));\n} catch (MappingError $e) {\n    $messages = (new NodeTraverser(function (Node $node) {\n        foreach ($node-\u003emessages() as $message) {\n            var_dump([\n                '$message',\n                $message-\u003epath(),\n                $message-\u003ebody()\n            ]);\n        }\n        return '';\n    }))-\u003etraverse($e-\u003enode());\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]=\u003e\n  string(8) \"$message\"\n  [1]=\u003e\n  string(1) \"a\"\n  [2]=\u003e\n  string(48) \"Given \"HAHA\" is not a recognized monetary amount\"\n}\narray(3) {\n  [0]=\u003e\n  string(8) \"$message\"\n  [1]=\u003e\n  string(1) \"c\"\n  [2]=\u003e\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.","aliases":["CVE-2022-31140"],"modified":"2023-11-08T04:09:27.300415Z","published":"2022-07-12T22:15:29Z","database_specific":{"cwe_ids":["CWE-200","CWE-209"],"severity":"HIGH","github_reviewed":true,"github_reviewed_at":"2022-07-12T22:15:29Z","nvd_published_at":"2022-07-11T20:15:00Z"},"references":[{"type":"WEB","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"},{"type":"WEB","url":"https://github.com/CuyZ/Valinor/releases/tag/0.12.0"}],"affected":[{"package":{"name":"cuyz/valinor","ecosystem":"Packagist","purl":"pkg:composer/cuyz/valinor"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"0.12.0"}]}],"versions":["0.1.0","0.1.1","0.10.0","0.11.0","0.2.0","0.3.0","0.4.0","0.5.0","0.6.0","0.7.0","0.8.0","0.9.0"],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2022/07/GHSA-5pgm-3j3g-2rc7/GHSA-5pgm-3j3g-2rc7.json"}}],"schema_version":"1.9.0","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N"}]}