Bypass of SSRF Vulnerability
The oEmbed fetch function in Ghost only blocked literal localhost, IPv4 and IPv6 hostnames, so a hostname that resolves to a loopback or internal address slipped past the check. An authenticated blog user could then make the server send GET requests to internal services such as cloud metadata endpoints.
- Disclosed after 13 months
##Bypass of SSRF report https://hackerone.com/reports/793704
Fix applied after reporting the actual report did not prevent from SSRF issue. https://github.com/TryGhost/Ghost/commit/47739396705519a36018686894d1373e9eb92216#diff-3aa52b4b8c6e0fb8422de65648e35887R101
The function fetchOembedData() only validates, IPv4, IPv6 and localhost:
if (!HTTP_REGEX.test(protocol) || hostname === 'localhost' || IPV4_REGEX.test(hostname) || IPV6_REGEX.test(hostname))
However, it is possible that an attacker would be able to bypass localhost validations with following domains or such:
http://spoofed.burpcollaborator.net http://localtest.me http://customer1.app.localhost.my.company.127.0.0.1.nip.io http://mail.ebc.apple.com redirect to 127.0.0.6 == localhost http://bugbounty.dod.network redirect to 127.0.0.2 == localhost
##Recommendation In order to fix, this vulnerability all the URL provided with "/ghost/api/v3/admin/oembed/?url=http://169.254.169.254/metadata/v1.json&type=embed" and URLs getting as a response should be resolved and it should again pass through the filters added to above functions.
Impact
- An attacker with publisher role (editor, author, contributor, administrator) in a blog may be able to leverage this to make arbitrary GET requests in a Ghost Blog instance's to internal external network.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the validation checked the hostname string against localhost and IP patterns without resolving the hostname first, so DNS names pointing to internal addresses bypassed the filter.
Impact
A user with a publisher role could make the Ghost instance send arbitrary GET requests to internal and external networks, potentially reaching cloud metadata services.
What the attacker needed
An account with a publisher role; ability to submit an oEmbed URL
The fix
The URL and any URLs returned in the response should be resolved and re-checked against the filters before being fetched.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
The blog software fetches a link you give it so it can show a preview. It tried to block links pointing at the server itself or the local network, but it only checked the text of the address, not where that address actually leads. A domain name that resolves to a local address got through, letting the server be tricked into contacting internal machines.
What is SSRF?
The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.