Skip to content

fix: redact credentials from request URLs in error messages - #1512

Open
pcbeingused33 wants to merge 3 commits into
CesiumGS:mainfrom
pcbeingused33:fix/redact-access-token-in-errors
Open

pcbeingused33 wants to merge 3 commits into
CesiumGS:mainfrom
pcbeingused33:fix/redact-access-token-in-errors

Conversation

@pcbeingused33

Copy link
Copy Markdown
Contributor

Fixes #1498

Description

When a network request fails, several error messages include the full request URL. For Cesium ion requests that URL carries the access_token query parameter, and other providers use key=. As a result the token ends up in logs, e.g. GET `https://api.cesium.com/v1/assets/<id>/endpoint?access_token=<token>` failed: ... from CurlAssetAccessor.

  • Add CesiumUtility::Uri::redactCredentials(uri), which replaces the values of the access_token and key query parameters with REDACTED. URIs that are invalid or have neither parameter are returned unchanged.
  • Use it in the error and warning messages of CurlAssetAccessor (both request paths), NetworkAssetDescriptor, IonRasterOverlay, CesiumIonTilesetLoader and RasterOverlayTileProvider. The requests themselves and the endpoint cache still use the original URL.

The redacted keys are limited to access_token and key; the list can be extended, or narrowed to access_token only, if preferred.

Issue number or link

Fixes #1498

Author checklist

  • I have submitted a Contributor License Agreement (only needed once).
  • I have done a full self-review of my code.
  • I have updated CHANGES.md with a short summary of my change (for user-facing changes).
  • I have added or updated unit tests to ensure consistent code coverage as necessary.
  • I have updated the documentation as necessary.

Testing plan

New Uri::redactCredentials cases in CesiumUtility/test/TestUri.cpp check that access_token is redacted, that key is redacted while other parameters are kept, and that URIs without credentials are left unchanged. They fail without the change and pass with it, and the existing TestUri.cpp cases still pass. These tests ran in a standalone build of Uri.cpp + TestUri.cpp against ada and doctest, not the full CMake/vcpkg build, so CI is the first full compile of the call-site changes. Changed files were formatted with the repo's pinned clang-format.

To reproduce the original issue: load a Cesium ion asset with a valid token while network requests fail (for example, a TLS failure), and look at the logged error. On main it contains access_token=<token>; on this branch it contains access_token=REDACTED.

This change and its tests were prepared with the help of an AI coding assistant.

Failed network requests reported the full request URL, which for
Cesium ion includes the access_token query parameter, so tokens leaked
into logs. Add Uri::redactCredentials and use it when formatting
request failures.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cesium ion access token is written to logs in failed request URLs

1 participant