Skip to content

Commit c545513

Browse files
authored
Bugfix/Validate URL for postCore (#4172)
validare url for postCore
1 parent 2b9a1ae commit c545513

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

packages/components/nodes/chains/ApiChain/postCore.ts

+15
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,21 @@ export class APIChain extends BaseChain implements APIChainInput {
9292

9393
const { url, data } = JSON.parse(api_url_body)
9494

95+
// Validate request is not to internal/private networks
96+
const urlObj = new URL(url)
97+
const hostname = urlObj.hostname
98+
99+
if (
100+
hostname === 'localhost' ||
101+
hostname === '127.0.0.1' ||
102+
hostname.startsWith('192.168.') ||
103+
hostname.startsWith('10.') ||
104+
hostname.startsWith('172.16.') ||
105+
hostname.includes('internal')
106+
) {
107+
throw new Error('Access to internal networks is not allowed')
108+
}
109+
95110
const res = await fetch(url, {
96111
method: 'POST',
97112
headers: this.headers,

0 commit comments

Comments
 (0)