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

fix[SSRF]: Arbitrary File Read Vulnerability #5541

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions libs/langchain-community/src/document_loaders/web/playwright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,25 @@ export class PlaywrightWebBaseLoader
url: string,
options?: PlaywrightWebBaseLoaderOptions
): Promise<string> {
// fix: SSRF
// https://huntr.com/bounties/23f45984-7336-48d8-a373-75b39bcd6367
const isValidHttpUrl = (inputUrl: string): boolean => {
try {
const parsedUrl = new URL(inputUrl);
return (
parsedUrl.protocol === "http:" || parsedUrl.protocol === "https:"
);
} catch {
return false;
}
};

if (!isValidHttpUrl(url)) {
throw new Error(
"Invalid URL: Only HTTP and HTTPS protocols are allowed."
);
}

const { chromium } = await PlaywrightWebBaseLoader.imports();

const browser = await chromium.launch({
Expand Down