Use secureFetch in APIChain Logic#5677
Use secureFetch in APIChain Logic#5677christopherholland-workday wants to merge 1 commit intomainfrom
Conversation
Summary of ChangesHello @christopherholland-workday, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the security of the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request is a good step towards improving security by replacing node-fetch with the custom secureFetch to prevent Server-Side Request Forgery (SSRF) vulnerabilities in the APIChain logic. My main feedback is to remove the now-redundant manual IP address validation to rely solely on secureFetch. Additionally, I've noticed that other chains like GETApiChain and OpenAPIChain might still be using insecure fetch methods from the base langchain library. It would be beneficial to review them as well to ensure consistent SSRF protection across the application.
| } | ||
|
|
||
| const res = await fetch(url, { | ||
| const res = await secureFetch(url, { |
There was a problem hiding this comment.
By switching to secureFetch, you've introduced a centralized security check for SSRF. That's great! However, the manual check for internal networks from lines 99-108 is now redundant with the checks performed inside secureFetch (via checkDenyList). To avoid duplicated logic and rely on a single source for this security control, this manual block should be removed. This assumes that the HTTP_DENY_LIST environment variable will be configured to include these private ranges.
There was a problem hiding this comment.
Leaving the check in until the team finalizes the approach on how to proceed if HTTP_DENY_LIST isn't present, as today there is no code default.
|
The relevant changes are included inPR #5653, specifically in the commit feat(postCore.ts): swap fetch to secureFetch |
Details
This code was using
node-fetchinstead of the custom-builtsecureFetchmethod.secureFetchhas SSRF protection built in and should be the standard used in Flowise when making fetch calls.