Find, fix and prevent vulnerabilities in your code.
medium severity
- Vulnerable module: tmp
- Introduced through: inquirer@9.2.23 and @inquirer/prompts@5.3.8
Detailed paths
-
Introduced through: codewhisper@gmickel/CodeWhisper#8e4ad68882d74a8fbdcc257504e6777aa6eafdac › inquirer@9.2.23 › external-editor@3.1.0 › tmp@0.0.33
-
Introduced through: codewhisper@gmickel/CodeWhisper#8e4ad68882d74a8fbdcc257504e6777aa6eafdac › @inquirer/prompts@5.3.8 › @inquirer/editor@2.2.0 › external-editor@3.1.0 › tmp@0.0.33
Overview
Affected versions of this package are vulnerable to Symlink Attack via the dir
parameter. An attacker can cause files or directories to be written to arbitrary locations by supplying a crafted symbolic link that resolves outside the intended temporary directory.
PoC
const tmp = require('tmp');
const tmpobj = tmp.fileSync({ 'dir': 'evil-dir'});
console.log('File: ', tmpobj.name);
try {
tmp.fileSync({ 'dir': 'mydir1'});
} catch (err) {
console.log('test 1:', err.message)
}
try {
tmp.fileSync({ 'dir': '/foo'});
} catch (err) {
console.log('test 2:', err.message)
}
try {
const fs = require('node:fs');
const resolved = fs.realpathSync('/tmp/evil-dir');
tmp.fileSync({ 'dir': resolved});
} catch (err) {
console.log('test 3:', err.message)
}
Remediation
Upgrade tmp
to version 0.2.4 or higher.
References
medium severity
- Vulnerable module: nanoid
- Introduced through: ai@3.3.9, @ai-sdk/anthropic@0.0.43 and others
Detailed paths
-
Introduced through: codewhisper@gmickel/CodeWhisper#8e4ad68882d74a8fbdcc257504e6777aa6eafdac › ai@3.3.9 › nanoid@3.3.6Remediation: Upgrade to ai@3.4.20.
-
Introduced through: codewhisper@gmickel/CodeWhisper#8e4ad68882d74a8fbdcc257504e6777aa6eafdac › @ai-sdk/anthropic@0.0.43 › @ai-sdk/provider-utils@1.0.13 › nanoid@3.3.6Remediation: Upgrade to @ai-sdk/anthropic@0.0.53.
-
Introduced through: codewhisper@gmickel/CodeWhisper#8e4ad68882d74a8fbdcc257504e6777aa6eafdac › @ai-sdk/openai@0.0.48 › @ai-sdk/provider-utils@1.0.13 › nanoid@3.3.6Remediation: Upgrade to @ai-sdk/openai@0.0.70.
-
Introduced through: codewhisper@gmickel/CodeWhisper#8e4ad68882d74a8fbdcc257504e6777aa6eafdac › ai@3.3.9 › @ai-sdk/provider-utils@1.0.13 › nanoid@3.3.6Remediation: Upgrade to ai@3.4.20.
-
Introduced through: codewhisper@gmickel/CodeWhisper#8e4ad68882d74a8fbdcc257504e6777aa6eafdac › ollama-ai-provider@0.12.0 › @ai-sdk/provider-utils@1.0.7 › nanoid@3.3.6Remediation: Upgrade to ollama-ai-provider@0.16.0.
-
Introduced through: codewhisper@gmickel/CodeWhisper#8e4ad68882d74a8fbdcc257504e6777aa6eafdac › ai@3.3.9 › @ai-sdk/ui-utils@0.0.33 › @ai-sdk/provider-utils@1.0.13 › nanoid@3.3.6Remediation: Upgrade to ai@3.4.20.
-
Introduced through: codewhisper@gmickel/CodeWhisper#8e4ad68882d74a8fbdcc257504e6777aa6eafdac › ai@3.3.9 › @ai-sdk/react@0.0.45 › @ai-sdk/provider-utils@1.0.13 › nanoid@3.3.6Remediation: Upgrade to ai@3.4.20.
-
Introduced through: codewhisper@gmickel/CodeWhisper#8e4ad68882d74a8fbdcc257504e6777aa6eafdac › ai@3.3.9 › @ai-sdk/solid@0.0.36 › @ai-sdk/provider-utils@1.0.13 › nanoid@3.3.6Remediation: Upgrade to ai@3.4.20.
-
Introduced through: codewhisper@gmickel/CodeWhisper#8e4ad68882d74a8fbdcc257504e6777aa6eafdac › ai@3.3.9 › @ai-sdk/svelte@0.0.38 › @ai-sdk/provider-utils@1.0.13 › nanoid@3.3.6Remediation: Upgrade to ai@3.4.20.
-
Introduced through: codewhisper@gmickel/CodeWhisper#8e4ad68882d74a8fbdcc257504e6777aa6eafdac › ai@3.3.9 › @ai-sdk/vue@0.0.37 › @ai-sdk/provider-utils@1.0.13 › nanoid@3.3.6Remediation: Upgrade to ai@3.4.20.
-
Introduced through: codewhisper@gmickel/CodeWhisper#8e4ad68882d74a8fbdcc257504e6777aa6eafdac › ai@3.3.9 › @ai-sdk/react@0.0.45 › @ai-sdk/ui-utils@0.0.33 › @ai-sdk/provider-utils@1.0.13 › nanoid@3.3.6Remediation: Upgrade to ai@3.4.20.
-
Introduced through: codewhisper@gmickel/CodeWhisper#8e4ad68882d74a8fbdcc257504e6777aa6eafdac › ai@3.3.9 › @ai-sdk/solid@0.0.36 › @ai-sdk/ui-utils@0.0.33 › @ai-sdk/provider-utils@1.0.13 › nanoid@3.3.6Remediation: Upgrade to ai@3.4.20.
-
Introduced through: codewhisper@gmickel/CodeWhisper#8e4ad68882d74a8fbdcc257504e6777aa6eafdac › ai@3.3.9 › @ai-sdk/svelte@0.0.38 › @ai-sdk/ui-utils@0.0.33 › @ai-sdk/provider-utils@1.0.13 › nanoid@3.3.6Remediation: Upgrade to ai@3.4.20.
-
Introduced through: codewhisper@gmickel/CodeWhisper#8e4ad68882d74a8fbdcc257504e6777aa6eafdac › ai@3.3.9 › @ai-sdk/vue@0.0.37 › @ai-sdk/ui-utils@0.0.33 › @ai-sdk/provider-utils@1.0.13 › nanoid@3.3.6Remediation: Upgrade to ai@3.4.20.
Overview
Affected versions of this package are vulnerable to Improper Input Validation due to the mishandling of fractional values in the nanoid
function. By exploiting this vulnerability, an attacker can achieve an infinite loop.
Remediation
Upgrade nanoid
to version 3.3.8, 5.0.9 or higher.
References
low severity
new
- Vulnerable module: jsondiffpatch
- Introduced through: ai@3.3.9
Detailed paths
-
Introduced through: codewhisper@gmickel/CodeWhisper#8e4ad68882d74a8fbdcc257504e6777aa6eafdac › ai@3.3.9 › jsondiffpatch@0.6.0Remediation: Upgrade to ai@5.0.0.
Overview
jsondiffpatch is a JSON diff & patch (object and array diff, text diff, multiple output formats)
Affected versions of this package are vulnerable to Cross-site Scripting (XSS) via HtmlFormatter::nodeBegin
. An attacker can inject malicious scripts into HTML payloads that may lead to code execution if untrusted payloads were used as source for the diff, and the result renderer using the built-in html formatter on a private website.
Details
Cross-site scripting (or XSS) is a code vulnerability that occurs when an attacker “injects” a malicious script into an otherwise trusted website. The injected script gets downloaded and executed by the end user’s browser when the user interacts with the compromised website.
This is done by escaping the context of the web application; the web application then delivers that data to its users along with other trusted dynamic content, without validating it. The browser unknowingly executes malicious script on the client side (through client-side languages; usually JavaScript or HTML) in order to perform actions that are otherwise typically blocked by the browser’s Same Origin Policy.
Injecting malicious code is the most prevalent manner by which XSS is exploited; for this reason, escaping characters in order to prevent this manipulation is the top method for securing code against this vulnerability.
Escaping means that the application is coded to mark key characters, and particularly key characters included in user input, to prevent those characters from being interpreted in a dangerous context. For example, in HTML, <
can be coded as <
; and >
can be coded as >
; in order to be interpreted and displayed as themselves in text, while within the code itself, they are used for HTML tags. If malicious content is injected into an application that escapes special characters and that malicious content uses <
and >
as HTML tags, those characters are nonetheless not interpreted as HTML tags by the browser if they’ve been correctly escaped in the application code and in this way the attempted attack is diverted.
The most prominent use of XSS is to steal cookies (source: OWASP HttpOnly) and hijack user sessions, but XSS exploits have been used to expose sensitive information, enable access to privileged services and functionality and deliver malware.
Types of attacks
There are a few methods by which XSS can be manipulated:
Type | Origin | Description |
---|---|---|
Stored | Server | The malicious code is inserted in the application (usually as a link) by the attacker. The code is activated every time a user clicks the link. |
Reflected | Server | The attacker delivers a malicious link externally from the vulnerable web site application to a user. When clicked, malicious code is sent to the vulnerable web site, which reflects the attack back to the user’s browser. |
DOM-based | Client | The attacker forces the user’s browser to render a malicious page. The data in the page itself delivers the cross-site scripting data. |
Mutated | The attacker injects code that appears safe, but is then rewritten and modified by the browser, while parsing the markup. An example is rebalancing unclosed quotation marks or even adding quotation marks to unquoted parameters. |
Affected environments
The following environments are susceptible to an XSS attack:
- Web servers
- Application servers
- Web application environments
How to prevent
This section describes the top best practices designed to specifically protect your code:
- Sanitize data input in an HTTP request before reflecting it back, ensuring all data is validated, filtered or escaped before echoing anything back to the user, such as the values of query parameters during searches.
- Convert special characters such as
?
,&
,/
,<
,>
and spaces to their respective HTML or URL encoded equivalents. - Give users the option to disable client-side scripts.
- Redirect invalid requests.
- Detect simultaneous logins, including those from two separate IP addresses, and invalidate those sessions.
- Use and enforce a Content Security Policy (source: Wikipedia) to disable any features that might be manipulated for an XSS attack.
- Read the documentation for any of the libraries referenced in your code to understand which elements allow for embedded HTML.
Remediation
Upgrade jsondiffpatch
to version 0.7.2 or higher.