{"id":1111,"cve":"CVE-2024-21624","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2024-21624\/","cwe":"CWE-200","cwe_number":200,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/200","cvss_score":6.5,"published":"2024-02-09","owasp":"A02 Cryptographic Failures","odc":"Interface","cdc":"Missing Check","category":"Information Leakage","subcategory":"Information Disclosure","scope":"Remote","impact":"Information Disclosure","summary":"Potential information leak in MessageTemplate with user input in nonebot2.","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2024-21624\/","description":"nonebot2 is a cross-platform Python asynchronous chatbot framework written in Python. This security advisory pertains to a potential information leak (e.g., environment variables) in instances where developers utilize `MessageTemplate` and incorporate user-provided data into templates. The identified vulnerability has been remedied in pull request #2509 and will be included in versions released from 2.2.0. Users are strongly advised to upgrade to these patched versions to safeguard against the vulnerability. A temporary workaround involves filtering underscores before incorporating user input into the message template.","solution":"Upgrade to version 2.2.0 or later.","affected_component":"nonebot2","fixed_by_upgrading":true,"vulnerable_code":"from nonebot import MessageTemplate\n\nuser_input = \"User 's secret: ${SECRET_ENV_VAR}\"\n\ntemplate = MessageTemplate(\"Here is your message: {message}\")\nmessage = template.render(message=user_input)\n\nprint(message)","patched_code":"from nonebot import MessageTemplate\n\nuser_input = \"User 's secret: ${SECRET_ENV_VAR}\"\n\nreplaced_input = user_input.replace(\"_\", \"\")\n\ntemplate = MessageTemplate(\"Here is your message: {message}\")\nmessage = template.render(message=replaced_input)\n\nprint(message)","payload_needed":true,"payload":"```python\n\"${SECRET_ENV_VAR}\"\n```","payload_status":"available","published_fix":[{"repository":"nonebot\/nonebot2","commit_url":"https:\/\/github.com\/nonebot\/nonebot2\/commit\/b65b3b438c95894654fd9081139989c757bdc6c1","commit_subject":":bug: Fix: `MessageTemplate` \u7981\u6b62\u8bbf\u95ee\u79c1\u6709\u5c5e\u6027 (#2509)","units":[{"file":"nonebot\/internal\/adapter\/template.py","function":null},{"file":"nonebot\/internal\/adapter\/template.py","function":"MessageTemplate.__init__"},{"file":"nonebot\/internal\/adapter\/template.py","function":"MessageTemplate.__init__#2"},{"file":"nonebot\/internal\/adapter\/template.py","function":"MessageTemplate.__init__#3"}]}],"references":null}