CVE-2023-27587 (published 2023-03-13T22:15Z)

ReadtoMyShoe, a web app that lets users upload articles and listen to them later, generates an error message containing sensitive information prior to commit 8533b01. If an error occurs when adding an article, the website shows the user an error message. If the error originates from the Google Cloud TTS request, then it will include the full URL of the request. The request URL contains the Google Cloud API key. This has been patched in commit 8533b01. Upgrading should be accompanied by deleting the current GCP API key and issuing a new one. There are no known workarounds.

CVSS v3 base score: 6.5, MEDIUM (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N)

Weakness information:
cwe_id: CWE-209
cwe_name: Generation of Error Message Containing Sensitive Information
description: The product generates an error message that includes sensitive information about its environment, users, or associated data.
extended_description: The sensitive information may be valuable information on its own (such as a password), or it may be useful for launching other, more serious attacks. The error message may be created in different ways:
           
             self-generated: the source code explicitly constructs the error message and delivers it
	     externally-generated: the external environment, such as a language interpreter, handles the error and constructs its own message, whose contents are not under direct control by the programmer
	   
	 An attacker may use the contents of error messages to help launch another, more focused attack. For example, an attempt to exploit a path traversal weakness (CWE-22) might yield the full pathname of the installed application. In turn, this could be used to select the proper number of ".." sequences to navigate to the targeted file. An attack using SQL injection (CWE-89) might not initially succeed, but an error message could reveal the malformed query, which would expose query logic and possibly even passwords or other sensitive information used within the query.
         

Fix information:
repo_url: https://github.com/rozbb/readtomyshoe
commit_details: repo_url: https://github.com/rozbb/readtomyshoe
author: Michael Rosenberg
author_date: 2023-03-13 14:13:23-04:00
msg: Fixed leakage of GCP API key through TTS error message
repository: repo_url: https://github.com/rozbb/readtomyshoe
repo_name: rozbb/readtomyshoe
description: A webapp that reads your articles to you while you're on the subway
repo_language: Rust
owner: rozbb
file_changes: filename: tts.rs
change_type: ModificationType.MODIFY
diff: @@ -85,6 +85,14 @@ pub(crate) fn get_api_key() -> Result<String, AnyError> {
     })
 }
 
+/// Redacts the API key out of the TTS error message
+fn redact_error(mut e: reqwest::Error) -> reqwest::Error {
+    // The API key is specified by `?key=...`. Overwriting the query section of the URL will make
+    // this go away
+    e.url_mut().map(|u| u.set_query(Some("key=REDACTED")));
+    e
+}
+
 /// Speaks text string of length at most MAX_CHARS_PER_REQUEST. Returns an error if length exceeds,
 /// or an error occurs in the Google Cloud API call.
 pub(crate) async fn tts_single(api_key: &str, req: &TtsRequest) -> Result<Bytes, AnyError> {
@@ -106,6 +114,7 @@ pub(crate) async fn tts_single(api_key: &str, req: &TtsRequest) -> Result<Bytes,
         .await
         .with_context(|| "Couldn't make TTS request")?
         .error_for_status()
+        .map_err(redact_error)
         .with_context(|| "TTS request failed")?;
 
     // The resulting JSON response has our MP3 data

programming_language: Rust