Skip to content

How can my server avoid turning result downloads into an arbitrary URL fetcher?

Fetch results through documented task identities and trusted service origins rather than accepting arbitrary customer-supplied download URLs. If your application follows redirects, validate every destination under a reviewed SSRF policy. Authorization to retrieve an AISwapLab task does not authorize your server to fetch any network address.

PROTECT API ACCESS AND RESULTSAISwapLab team · Editorial methodUpdated 2 min read
Open API documentationExplore 67 Image SkillsPrivate keys · Explicit credit approval
Article workflow: Construct from trusted identifiers; Review redirect handling; Test hostile destinations offline.
Workflow diagram: Construct from trusted identifiers → Review redirect handling → Test hostile destinations offline. Read the article for evidence and limits.

A convenience proxy can become a network bridge

A generic fetch-this-URL route can reach internal services or leak credentials if it forwards headers across hosts. A private result proxy should know which task and content route it is serving, with no need for users to select arbitrary destinations.

What to do next

  1. 01

    Construct from trusted identifiers

    Accept an application asset or task ID, authorize it, and construct the documented upstream route on the server. Avoid taking a full URL from a query string or model-generated text as the fetch destination.

  2. 02

    Review redirect handling

    Disable redirects when unnecessary or validate each redirected scheme, host, port and resolved destination. Never forward upstream authorization to an untrusted origin, and apply network egress restrictions as an additional control.

  3. 03

    Test hostile destinations offline

    Exercise localhost, private-network addresses, unexpected schemes and a trusted-looking URL that redirects elsewhere using controlled fixtures. Confirm rejection happens before contacting an unapproved destination or forwarding credentials.

A concrete example

Illustrative example: the browser requests asset A17, not a URL. The server resolves A17 to its authorized documented content path. A fixture redirect to an internal address is rejected instead of being followed with the bearer header.

Before you call it ready

  • Clients submit identifiers rather than fetch URLs.
  • Each redirect is policy-checked.
  • Credentials never cross to an untrusted origin.

A locally executed, reproducible check

A relative-location resolver can replace the expected host when the location is scheme-relative or absolute.

We executed this exact synthetic fixture on November 16, 2026 with Python 3.12.10 and SQLite 3.49.1. It ran locally with no network requests, account data or model generation. The recorded output below is an observation from that environment, not a platform benchmark. Copy the code into a separate Python file to repeat it in a suitable local environment; compare the mechanism and check your runtime version.

python
from urllib.parse import urljoin,urlsplit
base='https://media.example.invalid/private/output'
for location in ('next.png','//other.example.invalid/file.png','https://other.example.invalid/file.png'):
    resolved=urljoin(base,location)
    print('resolved:',resolved,'host:',urlsplit(resolved).hostname)

Recorded output and interpretation

This resolves synthetic strings only; it makes no HTTP request and does not model a particular HTTP client’s credential forwarding. Validate each actual redirect hop against your policy before fetching; do not infer safety from the original URL alone.

A matching local output establishes only the illustrated library or database behavior under these inputs. It does not certify a production integration. Preserve the approved action, authorization boundaries and current AISwapLab request contract when applying the idea.

text
resolved: https://media.example.invalid/private/next.png host: media.example.invalid
resolved: https://other.example.invalid/file.png host: other.example.invalid
resolved: https://other.example.invalid/file.png host: other.example.invalid

When to stop or choose another method

Stop exposing a generic server fetch proxy as a shortcut for authenticated result delivery.

Sources

One task. A recoverable workflow.

Check the contract, approve the quote and retain the job.

Open API documentation