Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only build payload paths on attack #473

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Conversation

timokoessler
Copy link
Contributor

  • Find multiple occurrences in same source

+ Find multiple occurrences in same source
Copy link

codecov bot commented Dec 9, 2024

Codecov Report

Attention: Patch coverage is 98.03922% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
library/agent/Agent.ts 66.66% 1 Missing ⚠️
library/sinks/HTTPRequest.ts 0.00% 1 Missing ⚠️
library/sinks/undici/wrapDispatch.ts 50.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@timokoessler timokoessler marked this pull request as ready for review December 9, 2024 12:34
Comment on lines 27 to 32
if (path === ".origin" || path === ".referer") {
const url = tryParseURL(str);
if (!!url && url.host === `localhost:${port}`) {
ignoredPaths++;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has become complex. Any way to avoid?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, the !! is no longer necessary.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same feeling

@@ -211,7 +211,7 @@ function wrapDNSLookupCallback(
if (agent.shouldBlock()) {
return callback(
new Error(
`Zen has blocked ${attackKindHumanName("ssrf")}: ${operation}(...) originating from ${found.source}${escapeHTML(found.pathToPayload)}`
`Zen has blocked ${attackKindHumanName("ssrf")}: ${operation}(...) originating from ${found.source}${escapeHTML(found.pathsToPayload.join())}`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defend vs potential crash

@@ -110,7 +110,7 @@ function blockRedirectToPrivateIP(url: URL, context: Context, agent: Agent) {

if (agent.shouldBlock()) {
throw new Error(
`Zen has blocked ${attackKindHumanName("ssrf")}: fetch(...) originating from ${found.source}${escapeHTML(found.pathToPayload)}`
`Zen has blocked ${attackKindHumanName("ssrf")}: fetch(...) originating from ${found.source}${escapeHTML(found.pathsToPayload.join())}`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defend vs potential crash


const attackPayloadLowercase = attackPayload.toLowerCase();

const traverse = (value: unknown, path: PathPart[] = []) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add a max_depth

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this is only executed in case of an attack, it's not so important for performance, or?

library/helpers/attackPath.ts Outdated Show resolved Hide resolved
Comment on lines 27 to 32
if (path === ".origin" || path === ".referer") {
const url = tryParseURL(str);
if (!!url && url.host === `localhost:${port}`) {
ignoredPaths++;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same feeling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants