Skip to content

Axios ignoring allowAbsoluteUrls configuration parameter #6806

Description

@david-arien

Describe the bug

Starting from Axios v1.8.0, the allowAbsoluteUrls attribute was introduced in the configuration to control the use of absolute URLs. (PR: #6795)

Currently, this parameter is being ignored in the buildFullPath call from the HTTP adapter.

const fullPath = buildFullPath(config.baseURL, config.url);

This oversight means that it is still possible to make requests to absolute URLs even when the allowAbsoluteUrls configuration attribute is set to false.

Proof of Concept:

Even though getUri returns a URL from example.com, the request is sent to evil.com

> const axios = require('axios');
> axios.VERSION
'1.8.1'
> const client = axios.create({baseURL: 'http://example.com/', allowAbsoluteUrls: false});
> client.getUri({url: 'http://evil.com'});
'http://example.com/http://evil.com'
> client.get('http://evil.com');

Solution:

Include the allowAbsoluteUrls parameter in the call to the buildFullPath function.

const fullPath = buildFullPath(config.baseURL, config.url);

const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);

To Reproduce

No response

Code snippet

const axios = require('axios');
const client = axios.create({baseURL: 'http://example.com/', allowAbsoluteUrls: false});
client.get('http://evil.com');

Expected behavior

The request should be to example.com

Axios Version

1.8.0

Adapter Version

http

Browser

No response

Browser Version

No response

Node.js Version

22.12.0

OS

Debian 5.10.226-1

Additional Library Versions

Additional context/Screenshots

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions