CVE-2024-39899: Privatebin/privatebin PrivateBin Allows Shortening Of URLs Vulnerability
MODERATECVE-2024-39899 is a MODERATE (CVSS 5.3) privatebin allows shortening of urls vulnerability (CWE-791: Incomplete Filtering of Special Elements) affecting Privatebin/privatebin libraries in the Packagist ecosystem. The issue involves privatebin allows shortening of urls for other domains. Remediation is available by upgrading affected packages to version 1.7.4.
CVE-2024-39899 at a Glance
Security Impact
CVSS: 5.3
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N).
How to Fix CVE-2024-39899
To remediate this vulnerability, upgrade all affected Privatebin/privatebin dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade privatebin/privatebin to 1.7.4
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for privatebin/privatebin
How to Check if You Are Affected
To determine whether your application is affected by CVE-2024-39899, inspect your project dependencies for Privatebin/privatebin:
inspect dependencies for privatebin/privatebin
Analyze the terminal output to locate any version of Privatebin/privatebin in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.7.4), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-791: Incomplete Filtering of Special Elements, where the product receives data from an upstream component, but does not completely filter special elements before sending it to a downstream component. In Privatebin/privatebin, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2024-39899 Affected Privatebin/privatebin Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
privatebin/privatebin
|
Packagist |
≥ 1.5.0
< 1.7.4
|
1.7.4
|
References
Frequently Asked Questions
What is CVE-2024-39899?
Which Privatebin/privatebin versions are affected?
What version fixes CVE-2024-39899?
Is privatebin/privatebin affected?
What is the CVSS score of CVE-2024-39899?
What CWE is associated with CVE-2024-39899?
How can I check Packagist dependencies for CVE-2024-39899?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-mqqj-fx8h-437j",
"modified" : "2024-07-12T13:22:14Z",
"published" : "2024-07-10T14:25:23Z",
"aliases" : [ "CVE-2024-39899" ],
"summary" : "PrivateBin allows shortening of URLs for other domains",
"details" : "In [v1.5](https://github.com/PrivateBin/PrivateBin/blob/master/CHANGELOG.md#15-2022-12-11) we introduced the YOURLS server-side proxy. The idea was to allow using the YOURLs URL shortener without running the YOURLs instance without authentication and/or exposing the authentication token to the public, allowing anyone to shorten any URL. With the proxy mechanism, anyone can shorten any URL pointing to the configured PrivateBin instance. The vulnerability allowed other URLs to be shortened, as long as they contain the PrivateBin instance, defeating the limit imposed by the proxy.\n\nNeither the confidentially of existing pastes on the server nor the configuration options including the YOURLs token are affected.\n\n### Impact\n\nThis issue only affects non-standard configurations of PrivateBin. Instances are affected if all of the following conditions are met:\n1. The PrivateBin instance enables URL shortening.\n2. A YOURLs URL shortener is used and it is configured not to be public and require authentication to shorten URLs.\n3. A basepath, the YOURLs proxy mechanism and an authentication token is configured in PrivateBin to use the non-public YOURLs instance.\n4. A crafted URL is sent to PrivateBins' YOURLs proxy endpoint with a URL that contains the PrivateBin instance URL as a GET-parameter or as part of the URL-fragment, but doesn't start with the instance URL (a third-party URL)\n\nThe root cause is, [that the guard clause checking whether the URL to be shortened belongs to your own PrivateBin domain only checks if the PrivateBin instance is contained in the URL](https://github.com/PrivateBin/PrivateBin/blob/3cba170f3255de21bbebb77f6c565519ef33e8c1/lib/YourlsProxy.php#L50-L53) but not if it starts with it.\n\nThis is a kind of authentication bypass due to incomplete filtering. This [has a similar impact like an open redirect](https://cwe.mitre.org/data/definitions/601.html) except it does not directly redirect, but allows a further hiding of the target URL as is common and known for URL shorteners. If the URL shortener domain used is trusted by it's users, this allows hiding a malicious URL. \n\nThe highest impact may be that this can be used for phishing campaigns, by routing users to some kind of fake site mimicking the trusted shortener or PrivateBin domain, which could then extract sensitive data from entered data or similar. That said, this is a general concern with URL shorteners and users are advised to follow general phishing prevention attempts like verifying the domain of the site they are using and [using a trusted PrivateBin instance](https://github.com/PrivateBin/PrivateBin?tab=readme-ov-file#what-it-doesnt-provide).\n\n### Indicators of exploitation\n\nCheck your YOURLs proxy for shortened domains that do not start with your own PrivateBin instance. Also note, that for this to be a result of an exploitation of this vulnerability, somewhere in the URL the `base path + ?` e.g. `https://privatebin.example/?` has to appear in the destination URL, as this is what the guard checked for.\n\n### Patches\n\nThe problem has been patched in version 1.7.4 of PrivateBin. In addition to upgrading, users of the YOURLs proxy feature should check for the indicators of exploitation, as outlined above.\n\n### Workarounds\n\n* Disable URL shortening, if you have been using it.\n* Only the YOURLs proxy is affected. Other URL shortening options either require a public, un-authenticated shortener, or expose the token to the client, which by design allows shortening any URL.\n\n### Proof of concept\n\nSee [the unit test that got introduced](https://github.com/PrivateBin/PrivateBin/blob/2c711e9d3ca21230fc68f5b4dba2a7a0592b963b/tst/YourlsProxyTest.php#L57-L62) to prevent similar regressions for an example of a URL that would circumvent the configured basepath.\n\nHere is an example of how a manual exploitation would work:\n\nIn a PrivateBin instance hosted on `https://privatebin.example/`, with a valid URL YOURLs shortening proxy configuration using a token to prevent un-authenticated short-URL creation, send a URL shortening request for the domain `https://attacker.example.com/?q=https://privatebin.example/?foo#bar`. `attacker.example.com` is any attacker controlled, arbitrary domain.\n\nYou can do this by sending a GET request to `https://privatebin.example/shortenviayourls?link=https%3A%2F%2Fattacker.example.com%2F%3Fq%3Dhttps%3A%2F%2Fprivatebin.example%2F%3Ffoo%23bar`, without URL encoding this looks as follows: `https://privatebin.example/shortenviayourls?link=https://attacker.example.com/?q=https://privatebin.example/?foo#bar`.\n\nOn an affected setup, you will get a valid short URL, which when accessed, leads to `https://attacker.example.com/?foo#bar`, the attackers domain. On a patched system your request will get rejected and only URLs starting with `https://privatebin.example/?[...]` are allowed for shortening.\n\n### Post-mortem\n\nFrom our limited analysis, the issue [has been introduced in commit `0dc9ab7` while refactoring](https://github.com/PrivateBin/PrivateBin/commit/0dc9ab7576d5a1296debeb788afb2ae9c72d137c). The use of [`substr`](http://php.net/manual/function.substr.php) got replaced by [`strpos`](https://www.php.net/manual/function.strpos). The [initial contribution](https://github.com/PrivateBin/PrivateBin/commit/b0f17f0a91cdebbfd6732781943f1e04ce3311f7) contained no tests, but an implementation without this flaw. All these changes got introduced [in a single pull request](https://github.com/PrivateBin/PrivateBin/pull/997). This follows many best practices, as tests were added and the refactoring was done in close collaboration with the original author.\n\nIn the future, [we plan to switch to the more obvious, readable and understandable](https://github.com/PrivateBin/PrivateBin/issues/1373) [`str_starts_with`](https://www.php.net/manual/function.str-starts-with.php), which is available since PHP v8. Such a better function naming and insisting on using modern functions would not only result in a better code quality, but would possibly have prevented the issue, but for backwards-compatibility with PHP 7.3, we stay on the old function for now.\n\n### Final Thoughts\n\nThe project maintainers have always discouraged the use of URL shorteners and **users are always safer sharing the complete, long URL to a paste**, see [our FAQ](https://github.com/PrivateBin/PrivateBin/wiki/FAQ#the-url-is-so-long-cant-i-just-use-an-url-shortener).\n\nIf you need or want to provide a URL shortener option as a PrivateBin instance administrator, YOURLs is the _best option_ available to use with PrivateBin, because it is the only shortener supported, through the proxy mechanism, preventing arbitrarily shortening any URLs. Running a public URL shortener instance and allowing anonymous users shortening arbitrary domains invites the shortener getting abused.\n\n### References\n\n* PR to fix the vulnerability: https://github.com/PrivateBin/PrivateBin/pull/1370\n\n### Timeline\n\n- 2024-06-28 Issue report by @nbxiglk via email\n- 2024-06-29 Vulnerability reproduced by @elrido, mitigation created and shared with maintainers and issue reporter for review\n- 2024-07-06 Pull request with mitigation raised",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N"
}, {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Packagist",
"name" : "privatebin/privatebin"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "1.5.0"
}, {
"fixed" : "1.7.4"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/PrivateBin/PrivateBin/security/advisories/GHSA-mqqj-fx8h-437j"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-39899"
}, {
"type" : "WEB",
"url" : "https://github.com/PrivateBin/PrivateBin/pull/1370"
}, {
"type" : "WEB",
"url" : "https://github.com/PrivateBin/PrivateBin/commit/0c4e810e6728f67d678458838d8430dfba4fcca4"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/PrivateBin/PrivateBin"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-305", "CWE-791" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2024-07-10T14:25:23Z",
"nvd_published_at" : "2024-07-09T19:15:13Z"
}
}