Skip to main content
Menu
Advisories

SSRF via Insecure Default HTTP Policy in MontFerret/ferret

GHSA-CH6M-68Q4-4Q4GPublished Updated GitHub

Description

<html> <body> <!--StartFragment--><h2 data-pm-slice="1 3 []">1. Overview</h2><p><strong>Component</strong>: <a href="github.com/MontFerret/ferret">MontFerret/ferret</a> (FQL query engine)<br><strong>Type</strong>: Server-Side Request Forgery (SSRF, CWE-918)<br><strong>Severity</strong>: High<br><strong>Affected scope</strong>: All <code>ferret.Engine</code> instances created with default options<br><strong>Verified version</strong>: <code>github.com/MontFerret/ferret/v2@v2.0.0-alpha.33</code></p><p>Ferret exposes network helpers such as <code>IO::NET::HTTP::GET/POST/PUT/DELETE/DO</code> in FQL, allowing queries to issue HTTP requests from the server. The engine includes an HTTP access policy (<code>pkg/net/http/policy.go</code>) that can restrict dangerous targets such as localhost and private networks. However, <strong>the default policy disables those protections</strong>.</p><p>If an attacker can submit a controllable FQL query (or otherwise influence the URL used in the query), the server can be coerced to request:</p><ul><li><p>Local services (<code>127.0.0.1</code> / <code>localhost</code>)</p></li><li><p>Private networks (<code>10.0.0.0/8</code>, <code>172.16.0.0/12</code>, <code>192.168.0.0/16</code>, etc.)</p></li><li><p>Cloud metadata endpoints (e.g. <code>169.254.169.254</code>)</p></li></ul><p>Typical impact includes theft of cloud instance temporary credentials, probing and accessing internal admin APIs, and bypassing firewalls to reach services that are only reachable from the internal network. For a read-only scenario, the estimated CVSS 3.1 score is approximately <strong>8.6</strong> (AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N). Impact can be higher if internal services accept write operations.</p><hr><p></p><h2>2. Root Cause</h2><p></p><h3>2.1 Insecure defaults in <code>NewPolicies()</code></h3><p>The issue is in <code>NewPolicies()</code> in <code>pkg/net/http/policy.go</code>: when building the default policy, the dangerous flags are explicitly set to <code>true</code>.</p><pre><code class="language-go">// NewPolicies builds a policy set with Ferret's default HTTP policy values. func NewPolicies(setters ...Policy) Policies { p := Policies{ FollowRedirects: true, AllowedSchemes: []string{"http", "https"}, AllowLocalhost: true, // localhost allowed by default AllowPrivateNetworks: true, // private networks allowed by default } // ... return p }</code></pre><p>Validation logic itself exists (<code>validateURL</code> checks localhost / private IPs), but the defaults render it ineffective:</p> Check | Default | Effect -- | -- | -- AllowLocalhost | true | Allows 127.0.0.1, localhost, etc. AllowPrivateNetworks | true | Allows RFC1918 and similar private addresses AllowedSchemes | http, https | Permits common HTTP(S) schemes BlockedHosts | empty | No host denylist

<p>The library provides <code>WithAllowLocalhost(false)</code> and <code>WithAllowPrivateNetworks(false)</code>, but callers that use <code>ferret.New()</code> without tightening the policy remain in an insecure default state.</p><h3>2.2 Exploit chain (Source → Sink)</h3><pre><code>Attacker-controlled FQL URL → IO::NET::HTTP::GET(url) # pkg/stdlib/io/net/http/get.go → makeRequest() builds the request # request.go → defaultHTTPClient.Do() # pkg/net/http/client.go → toStdRequest() → Policies.Eval() # helpers.go / policy.go → validateURL() passes under defaults → stdlib http.Client.Do() sends the request → response body is returned as the FQL result</code></pre><p>Critical sink: the call to Go’s standard <code>http.Client.Do()</code> in <code>pkg/net/http/client.go</code>. The request uses an attacker-controlled URL, and the response can flow back into the query result.</p><h3>2.3 Conceptual malicious query</h3><pre><code class="language-fql">RETURN IO::NET::HTTP::GET("169.254.169.254/latest/meta-data/iam/security-credentials/")</code></pre><p>In a cloud environment, this query may read instance metadata; appending a role name may yield temporary access keys. Likewise, <code>http://127.0.0.1:&lt;port&gt;/...</code> can be used to probe local services.</p><hr><p></p><h2>3. Verification</h2><p><strong>Goal</strong>: Show that under the <strong>default Engine</strong>, FQL-issued HTTP requests can reach a service bound only to <code>127.0.0.1</code> (i.e., the policy does not block localhost SSRF). Do not contact real cloud metadata or attack real internal networks—use a local mock service only.</p><h3>3.1 Environment</h3><ul><li><p>WSL (Linux) + Go 1.22+</p></li><li><p>Dependency: <code>github.com/MontFerret/ferret/v2</code></p></li><li><p>Verification script: <code>goferret/ssrfpoc_main.go</code></p></li></ul><p></p><h3>3.2 Steps</h3><pre><code class="language-bash">cd /mnt/c/Users/sha/Documents/AutoCVE/goferret go mod init goferret-ssrf-poc # if not already initialized go get github.com/MontFerret/ferret/v2@latest go mod tidy go run ssrfpoc_main.go</code></pre><p>What the script does:</p><ol><li><p>Starts a mock internal service on <code>127.0.0.1:&lt;random-port&gt;</code> (including <code>/test</code>, mock IMDS, and mock <code>/admin</code>).</p></li><li><p>Creates an Engine with <code>ferret.New()</code> (default policy).</p></li><li><p>Runs several FQL queries: <code>RETURN TO_STRING(IO::NET::HTTP::GET("http://127.0.0.1:&lt;port&gt;/..."))</code>.</p></li><li><p>Counts hits on the mock service and compares response bodies.</p></li></ol><p></p><h3>3.3 Expected result</h3><p>On successful reproduction you should see output similar to:</p><pre><code class="language-text">[*] Internal service listening on http://127.0.0.1:xxxxx (localhost only)

=== Baseline: default Engine accessing localhost === Response&gt; "localhost-ssrf-ok"

=== Step 1: Read mock cloud metadata IAM role name via FQL === Response&gt; "ferret-internal-role"

=== Step 2: Read mock temporary cloud credentials by role name === Response&gt; "{\"AccessKeyId\":\"AKIA_LEAKED_KEY\",...}"

=== Step 3: Access mock internal admin panel === Response&gt; "INTERNAL ADMIN PANEL - localhost only"

=== Verdict === Internal service hit count: 4 VULNERABLE: default HTTP policy allows FQL access to localhost/private networks (SSRF)</code></pre><p>Pass criteria:</p><ul><li><p>FQL queries are not rejected by policy errors;</p></li><li><p>Response bodies match the local mock service;</p></li><li><p>Hit count ≥ 4.</p></li></ul><p></p><h3>3.4 Static confirmation</h3><p>Defaults are visible in the dependency source:</p><pre><code class="language-text">pkg/net/http/policy.go AllowLocalhost: true AllowPrivateNetworks: true</code></pre><p><code>TestNewPoliciesDefaultValues</code> in <code>policy_test.go</code> also asserts both defaults are <code>true</code>, consistent with the dynamic verification.</p><hr><p></p><h2>4. Remediation</h2><ol><li><p><strong>Change library defaults</strong>: set <code>AllowLocalhost</code> and <code>AllowPrivateNetworks</code> to <code>false</code> by default (secure by default).</p></li><li><p><strong>Tighten on the caller side</strong> (until upstream is fixed):</p><pre><code class="language-go"> // Pseudocode: inject policy into the HTTP client / Engine per actual API ferrethttp.New( ferrethttp.WithAllowLocalhost(false), ferrethttp.WithAllowPrivateNetworks(false), // as needed: WithAllowedHosts(...), WithBlockedHosts(...) )</code></pre></li><li><p><strong>Additional controls</strong>: host/IP allowlists, block link-local ranges (including <code>169.254.0.0/16</code>), prevent redirects into private networks, and authenticate/audit user-controlled FQL.</p></li><li><p><strong>Documentation</strong>: clearly state that the default policy permits private/localhost access and that production deployments must configure policy.</p></li></ol><!--EndFragment--> </body> </html>1. Overview

Component: MontFerret/ferret (FQL query engine) Type: Server-Side Request Forgery (SSRF, CWE-918) Severity: High Affected scope: All ferret.Engine instances created with default options Verified version: github.com/MontFerret/ferret/v2@v2.0.0-alpha.33

Ferret exposes network helpers such as IO::NET::HTTP::GET/POST/PUT/DELETE/DO in FQL, allowing queries to issue HTTP requests from the server. The engine includes an HTTP access policy (pkg/net/http/policy.go) that can restrict dangerous targets such as localhost and private networks. However, the default policy disables those protections.

If an attacker can submit a controllable FQL query (or otherwise influence the URL used in the query), the server can be coerced to request:

Local services (127.0.0.1 / localhost)

Private networks (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, etc.)

Cloud metadata endpoints (e.g. 169.254.169.254)

Typical impact includes theft of cloud instance temporary credentials, probing and accessing internal admin APIs, and bypassing firewalls to reach services that are only reachable from the internal network. For a read-only scenario, the estimated CVSS 3.1 score is approximately 8.6 (AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N). Impact can be higher if internal services accept write operations.

  1. Root Cause

2.1 Insecure defaults in NewPolicies()

The issue is in NewPolicies() in pkg/net/http/policy.go: when building the default policy, the dangerous flags are explicitly set to true.

// NewPolicies builds a policy set with Ferret's default HTTP policy values. func NewPolicies(setters ...Policy) Policies { p := Policies{ FollowRedirects: true, AllowedSchemes: []string{"http", "https"}, AllowLocalhost: true, // localhost allowed by default AllowPrivateNetworks: true, // private networks allowed by default } // ... return p }

Validation logic itself exists (validateURL checks localhost / private IPs), but the defaults render it ineffective:

Check

Default

Effect

AllowLocalhost

true

Allows 127.0.0.1, localhost, etc.

AllowPrivateNetworks

true

Allows RFC1918 and similar private addresses

AllowedSchemes

http, https

Permits common HTTP(S) schemes

BlockedHosts

empty

No host denylist

The library provides WithAllowLocalhost(false) and WithAllowPrivateNetworks(false), but callers that use ferret.New() without tightening the policy remain in an insecure default state.

2.2 Exploit chain (Source → Sink)

Attacker-controlled FQL URL → IO::NET::HTTP::GET(url) # pkg/stdlib/io/net/http/get.go → makeRequest() builds the request # request.go → defaultHTTPClient.Do() # pkg/net/http/client.go → toStdRequest() → Policies.Eval() # helpers.go / policy.go → validateURL() passes under defaults → stdlib http.Client.Do() sends the request → response body is returned as the FQL result

Critical sink: the call to Go’s standard http.Client.Do() in pkg/net/http/client.go. The request uses an attacker-controlled URL, and the response can flow back into the query result.

2.3 Conceptual malicious query

RETURN IO::NET::HTTP::GET("169.254.169.254/latest/meta-data/iam/security-credentials/")

In a cloud environment, this query may read instance metadata; appending a role name may yield temporary access keys. Likewise, 127.0.0.1:<port>/... can be used to probe local services.

  1. Verification

Goal: Show that under the default Engine, FQL-issued HTTP requests can reach a service bound only to 127.0.0.1 (i.e., the policy does not block localhost SSRF). Do not contact real cloud metadata or attack real internal networks—use a local mock service only.

3.1 Environment

WSL (Linux) + Go 1.22+

Dependency: github.com/MontFerret/ferret/v2

Verification script: goferret/ssrfpoc_main.go

3.2 Steps

cd /mnt/c/Users/sha/Documents/AutoCVE/goferret go mod init goferret-ssrf-poc # if not already initialized go get github.com/MontFerret/ferret/v2@latest go mod tidy go run ssrfpoc_main.go

What the script does:

Starts a mock internal service on 127.0.0.1:<random-port> (including /test, mock IMDS, and mock /admin).

Creates an Engine with ferret.New() (default policy).

Runs several FQL queries: RETURN TO_STRING(IO::NET::HTTP::GET("127.0.0.1:<port>/...")).

Counts hits on the mock service and compares response bodies.

3.3 Expected result

On successful reproduction you should see output similar to:

[*] Internal service listening on http://127.0.0.1:xxxxx (localhost only)

=== Baseline: default Engine accessing localhost === Response> "localhost-ssrf-ok"

=== Step 1: Read mock cloud metadata IAM role name via FQL === Response> "ferret-internal-role"

=== Step 2: Read mock temporary cloud credentials by role name === Response> "{\"AccessKeyId\":\"AKIA_LEAKED_KEY\",...}"

=== Step 3: Access mock internal admin panel === Response> "INTERNAL ADMIN PANEL - localhost only"

=== Verdict === Internal service hit count: 4 VULNERABLE: default HTTP policy allows FQL access to localhost/private networks (SSRF)

Pass criteria:

FQL queries are not rejected by policy errors;

Response bodies match the local mock service;

Hit count ≥ 4.

3.4 Static confirmation

Defaults are visible in the dependency source:

pkg/net/http/policy.go AllowLocalhost: true AllowPrivateNetworks: true

TestNewPoliciesDefaultValues in policy_test.go also asserts both defaults are true, consistent with the dynamic verification.

  1. Remediation

Change library defaults: set AllowLocalhost and AllowPrivateNetworks to false by default (secure by default).

Tighten on the caller side (until upstream is fixed):

// Pseudocode: inject policy into the HTTP client / Engine per actual API ferrethttp.New( ferrethttp.WithAllowLocalhost(false), ferrethttp.WithAllowPrivateNetworks(false), // as needed: WithAllowedHosts(...), WithBlockedHosts(...) )

Additional controls: host/IP allowlists, block link-local ranges (including 169.254.0.0/16), prevent redirects into private networks, and authenticate/audit user-controlled FQL.

Documentation: clearly state that the default policy permits private/localhost access and that production deployments must configure policy.

Affected versions

References

GitHub · MontFerret/ferret