diff --git src/org/openstreetmap/josm/actions/ShowStatusReportAction.java src/org/openstreetmap/josm/actions/ShowStatusReportAction.java
index ec1921344b..9acf29315f 100644
--- src/org/openstreetmap/josm/actions/ShowStatusReportAction.java
+++ src/org/openstreetmap/josm/actions/ShowStatusReportAction.java
@@ -51,6 +51,7 @@ import org.openstreetmap.josm.tools.Logging;
 import org.openstreetmap.josm.tools.PlatformHookUnixoid;
 import org.openstreetmap.josm.tools.PlatformManager;
 import org.openstreetmap.josm.tools.Shortcut;
+import org.openstreetmap.josm.tools.TextUtils;
 import org.openstreetmap.josm.tools.Utils;
 import org.openstreetmap.josm.tools.bugreport.BugReportSender;
 
@@ -308,7 +309,30 @@ public final class ShowStatusReportAction extends JosmAction {
         }
     }
 
-    private static String valueCleanup(Object value) {
+    /**
+     * Shortens and removes private information from a preference value used for status report, among them the API keys
+     * and tokens of URLs, e.g. of custom imagery.
+     * @param value preference value to cleanup
+     * @return shortened/anonymized value
+     */
+    static String valueCleanup(Object value) {
+        return valueCleanupStripped(stripUrls(value));
+    }
+
+    private static Object stripUrls(Object value) {
+        if (value instanceof String) {
+            return TextUtils.stripUrl((String) value);
+        } else if (value instanceof Map<?, ?>) {
+            Map<Object, Object> map = new LinkedHashMap<>();
+            ((Map<?, ?>) value).forEach((k, v) -> map.put(k, stripUrls(v)));
+            return map;
+        } else if (value instanceof Collection<?>) {
+            return ((Collection<?>) value).stream().map(ShowStatusReportAction::stripUrls).collect(Collectors.toList());
+        }
+        return value;
+    }
+
+    private static String valueCleanupStripped(Object value) {
         String valueString = value.toString();
         if (valueString.length() > 512 && value instanceof Collection<?>) {
             valueString = ((Collection<?>) value).stream().map(v -> {
diff --git src/org/openstreetmap/josm/io/remotecontrol/RequestProcessor.java src/org/openstreetmap/josm/io/remotecontrol/RequestProcessor.java
index 4d3dfd8f0a..6333fc05f5 100644
--- src/org/openstreetmap/josm/io/remotecontrol/RequestProcessor.java
+++ src/org/openstreetmap/josm/io/remotecontrol/RequestProcessor.java
@@ -52,6 +52,7 @@ import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler.RequestHan
 import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler.RequestHandlerOsmApiException;
 import org.openstreetmap.josm.io.remotecontrol.handler.VersionHandler;
 import org.openstreetmap.josm.tools.Logging;
+import org.openstreetmap.josm.tools.TextUtils;
 import org.openstreetmap.josm.tools.Utils;
 
 /**
@@ -224,7 +225,7 @@ public class RequestProcessor extends Thread {
                 sendInternalError(out, null);
                 return;
             }
-            Logging.info("RemoteControl received: " + get);
+            Logging.info("RemoteControl received: " + TextUtils.stripUrl(get)); // e.g. an OAuth 2.0 authorization code
 
             StringTokenizer st = new StringTokenizer(get);
             if (!st.hasMoreTokens()) {
diff --git src/org/openstreetmap/josm/tools/HttpClient.java src/org/openstreetmap/josm/tools/HttpClient.java
index 64f329768d..40fd0c3a65 100644
--- src/org/openstreetmap/josm/tools/HttpClient.java
+++ src/org/openstreetmap/josm/tools/HttpClient.java
@@ -157,7 +157,7 @@ public abstract class HttpClient {
             ConnectionResponse cr;
             try {
                 if (Logging.isDebugEnabled()) {
-                    Logging.debug("REQUEST HEADERS: {0}", headers);
+                    Logging.debug("REQUEST HEADERS: {0}", TextUtils.stripHeaders(headers));
                 }
                 cr = performConnection();
                 final boolean hasReason = !Utils.isEmpty(reasonForRequest);
@@ -171,7 +171,7 @@ public abstract class HttpClient {
                 );
                 if (Logging.isDebugEnabled()) {
                     try {
-                        Logging.debug("RESPONSE HEADERS: {0}", cr.getHeaderFields());
+                        Logging.debug("RESPONSE HEADERS: {0}", TextUtils.stripHeaders(cr.getHeaderFields()));
                     } catch (IllegalArgumentException e) {
                         Logging.warn(e);
                     }
@@ -246,9 +246,14 @@ public abstract class HttpClient {
     }
 
     protected final void logRequestBody() {
-        logRequest("{0} {1} ({2}) ...", requestMethod, url, Utils.getSizeString(requestBody.length, Locale.getDefault()));
+        logRequest("{0} {1} ({2}) ...", requestMethod, TextUtils.stripUrl(url.toString()),
+                Utils.getSizeString(requestBody.length, Locale.getDefault()));
         if (Logging.isTraceEnabled() && hasRequestBody()) {
-            Logging.trace("BODY: {0}", new String(requestBody, StandardCharsets.UTF_8));
+            final String body = new String(requestBody, StandardCharsets.UTF_8);
+            final String contentType = headers.get("Content-Type");
+            // a form-encoded body has the syntax of a query, e.g. an OAuth 2.0 token request with the client secret
+            Logging.trace("BODY: {0}", contentType != null && contentType.contains("application/x-www-form-urlencoded")
+                    ? TextUtils.stripUrl(body) : body);
         }
     }
 
diff --git src/org/openstreetmap/josm/tools/TextUtils.java src/org/openstreetmap/josm/tools/TextUtils.java
index a30d7e35ff..f7c56cbc40 100644
--- src/org/openstreetmap/josm/tools/TextUtils.java
+++ src/org/openstreetmap/josm/tools/TextUtils.java
@@ -1,12 +1,29 @@
 // License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.tools;
 
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
 /**
  * Text/String utils.
  * @since 13978
  */
 public final class TextUtils {
 
+    /** What private information is replaced with */
+    private static final String STRIPPED = "...stripped...";
+    /**
+     * The parameters which are private: API keys and tokens, and OAuth 2.0 client secrets, authorization codes and
+     * their verifiers, and passwords. {@code code} is only matched as a whole name, so as not to strip e.g. a postcode.
+     * A value ends at white space too, so that what follows a URL in a log line is kept.
+     */
+    private static final Pattern PRIVATE_PARAMETERS =
+            Pattern.compile("(token|key|connectId|secret|password|(?<![\\w-])code|verifier)=[^&\\s]+");
+
     private TextUtils() {
         // Hide default constructor for utils classes
     }
@@ -22,13 +39,47 @@ public final class TextUtils {
     }
 
     /**
-     * Remove privacy related parts from output URL
+     * Remove privacy related parts from output URL.
+     * <p>
+     * This works for a form-encoded ({@code application/x-www-form-urlencoded}) request body as well, which has the
+     * syntax of a query, such as an OAuth 2.0 token request with its client secret.
      * @param url Unmodified URL
      * @return Stripped URL (privacy related issues removed)
      * @since 18652
      */
     public static String stripUrl(String url) {
-        return url.replaceAll("(token|key|connectId)=[^&]+", "$1=...stripped...");
+        return PRIVATE_PARAMETERS.matcher(url).replaceAll("$1=" + STRIPPED);
+    }
+
+    /**
+     * Remove privacy related values from output HTTP headers: those of {@code Authorization} and
+     * {@code Proxy-Authorization}, but for their scheme, so that the output still tells which kind of authentication
+     * was used, and those of {@code Cookie} and {@code Set-Cookie}.
+     * @param headers Unmodified headers, with a single value or a list of values for each
+     * @return Stripped copy of the headers, in the same order (privacy related issues removed)
+     * @since xxx
+     */
+    public static Map<String, Object> stripHeaders(Map<String, ?> headers) {
+        final Map<String, Object> stripped = new LinkedHashMap<>(headers);
+        stripped.replaceAll((key, value) -> {
+            final String name = key == null ? "" : key.toLowerCase(Locale.ROOT);
+            if ("authorization".equals(name) || "proxy-authorization".equals(name)) {
+                return stripHeaderValue(value, true);
+            } else if ("cookie".equals(name) || "set-cookie".equals(name)) {
+                return stripHeaderValue(value, false);
+            }
+            return value;
+        });
+        return stripped;
+    }
+
+    private static Object stripHeaderValue(Object value, boolean keepScheme) {
+        if (value instanceof List) {
+            return ((List<?>) value).stream().map(v -> stripHeaderValue(v, keepScheme)).collect(Collectors.toList());
+        }
+        final String text = String.valueOf(value);
+        final int space = text.indexOf(' ');
+        return (keepScheme && space > 0 ? text.substring(0, space + 1) : "") + STRIPPED;
     }
 
 }
diff --git test/unit/org/openstreetmap/josm/actions/ShowStatusReportActionTest.java test/unit/org/openstreetmap/josm/actions/ShowStatusReportActionTest.java
new file mode 100644
index 0000000000..60c15da87d
--- /dev/null
+++ test/unit/org/openstreetmap/josm/actions/ShowStatusReportActionTest.java
@@ -0,0 +1,38 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.actions;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.junit.jupiter.api.Test;
+import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
+
+/**
+ * Unit tests of {@link ShowStatusReportAction}.
+ */
+@BasicPreferences
+class ShowStatusReportActionTest {
+    /**
+     * The API keys and tokens in the URLs of preference values, e.g. of custom imagery, are stripped from the status
+     * report; other values are kept.
+     */
+    @Test
+    void testValueCleanupStripsUrls() {
+        assertEquals("https://tiles.example.org/{zoom}/{x}/{y}.png?apikey=...stripped...",
+                ShowStatusReportAction.valueCleanup("https://tiles.example.org/{zoom}/{x}/{y}.png?apikey=a-secret-key"));
+
+        final Map<String, String> imagery = new LinkedHashMap<>();
+        imagery.put("name", "Custom");
+        imagery.put("url", "https://tiles.example.org/{zoom}/{x}/{y}.png?access_token=a-secret-token");
+        assertEquals("[{name=Custom, url=https://tiles.example.org/{zoom}/{x}/{y}.png?access_token=...stripped...}]",
+                ShowStatusReportAction.valueCleanup(Collections.singletonList(imagery)));
+
+        assertEquals("[[https://example.org/?key=...stripped..., other]]", ShowStatusReportAction.valueCleanup(
+                Collections.singletonList(Arrays.asList("https://example.org/?key=a-secret-key", "other"))));
+        assertEquals("[a, b]", ShowStatusReportAction.valueCleanup(Arrays.asList("a", "b")));
+    }
+}
diff --git test/unit/org/openstreetmap/josm/io/remotecontrol/RemoteControlTest.java test/unit/org/openstreetmap/josm/io/remotecontrol/RemoteControlTest.java
index 304ff15206..141561f1a7 100644
--- test/unit/org/openstreetmap/josm/io/remotecontrol/RemoteControlTest.java
+++ test/unit/org/openstreetmap/josm/io/remotecontrol/RemoteControlTest.java
@@ -2,6 +2,8 @@
 package org.openstreetmap.josm.io.remotecontrol;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -9,6 +11,11 @@ import java.net.HttpURLConnection;
 import java.net.URL;
 import java.nio.charset.StandardCharsets;
 import java.security.GeneralSecurityException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.logging.Handler;
+import java.util.logging.LogRecord;
 
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
@@ -16,6 +23,7 @@ import org.junit.jupiter.api.Test;
 import org.openstreetmap.josm.spi.preferences.Config;
 import org.openstreetmap.josm.testutils.annotations.AssertionsInEDT;
 import org.openstreetmap.josm.testutils.annotations.HTTPS;
+import org.openstreetmap.josm.tools.Logging;
 
 /**
  * Unit tests for Remote Control
@@ -53,6 +61,44 @@ class RemoteControlTest {
         testListOfCommands(httpBase);
     }
 
+    /**
+     * The OAuth 2.0 authorization code of the redirect to Remote Control is not written to the log.
+     * @throws Exception if an error occurs
+     */
+    @Test
+    void testAuthorizationCodeIsNotLogged() throws Exception {
+        final List<String> logged = Collections.synchronizedList(new ArrayList<>());
+        final Handler handler = new Handler() {
+            @Override
+            public void publish(LogRecord logRecord) {
+                logged.add(String.valueOf(logRecord.getMessage()));
+            }
+
+            @Override
+            public void flush() {
+                // nothing to flush
+            }
+
+            @Override
+            public void close() {
+                // nothing to close
+            }
+        };
+        Logging.getLogger().addHandler(handler);
+        try {
+            HttpURLConnection connection = (HttpURLConnection) new URL(httpBase
+                    + "/oauth_authorization?code=a-secret-code&state=a-state").openConnection();
+            connection.connect();
+            connection.getResponseCode();
+            connection.disconnect();
+        } finally {
+            Logging.getLogger().removeHandler(handler);
+        }
+        final String log = String.join("\n", logged);
+        assertTrue(log.contains("RemoteControl received: GET /oauth_authorization?code=...stripped...&state=a-state"), log);
+        assertFalse(log.contains("a-secret-code"), log);
+    }
+
     private void testListOfCommands(String url) throws IOException, ReflectiveOperationException {
         HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
         connection.connect();
diff --git test/unit/org/openstreetmap/josm/tools/HttpClientCredentialsLoggingTest.java test/unit/org/openstreetmap/josm/tools/HttpClientCredentialsLoggingTest.java
new file mode 100644
index 0000000000..1d1feb67c4
--- /dev/null
+++ test/unit/org/openstreetmap/josm/tools/HttpClientCredentialsLoggingTest.java
@@ -0,0 +1,112 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.tools;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.SimpleFormatter;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
+import org.openstreetmap.josm.testutils.annotations.BasicWiremock;
+import org.openstreetmap.josm.testutils.annotations.HTTP;
+
+import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
+
+/**
+ * Credentials are not written to the log by {@link HttpClient}: debug and trace logs are often posted in public
+ * tickets. The stripping itself is tested in {@link TextUtilsTest}.
+ */
+@BasicPreferences
+@BasicWiremock
+@HTTP
+class HttpClientCredentialsLoggingTest {
+    private static final String TOKEN = "a-secret-bearer-token";
+    private static final String COOKIE = "a-secret-session-cookie";
+    private static final String CLIENT_SECRET = "a-secret-client-secret";
+
+    private final List<String> logged = Collections.synchronizedList(new ArrayList<>());
+    private final SimpleFormatter formatter = new SimpleFormatter();
+    private final Handler handler = new Handler() {
+        @Override
+        public void publish(LogRecord logRecord) {
+            logged.add(formatter.formatMessage(logRecord));
+        }
+
+        @Override
+        public void flush() {
+            // nothing to flush
+        }
+
+        @Override
+        public void close() {
+            // nothing to close
+        }
+    };
+    private Level level;
+
+    @BeforeEach
+    void setUp() {
+        level = Logging.getLogger().getLevel();
+        Logging.getLogger().addHandler(handler);
+        Logging.setLogLevel(Logging.LEVEL_TRACE);
+    }
+
+    @AfterEach
+    void tearDown() {
+        Logging.getLogger().removeHandler(handler);
+        Logging.setLogLevel(level);
+    }
+
+    /**
+     * A request with a bearer token, answered with a session cookie, and a token request with a client secret, are
+     * logged at trace level without any of them.
+     * @param wireMock the server answering the requests
+     * @throws Exception if a request fails
+     */
+    @Test
+    void testRequestsAreLoggedWithoutCredentials(WireMockRuntimeInfo wireMock) throws Exception {
+        wireMock.getWireMock().register(get(urlEqualTo("/api/0.6/user/details"))
+                .willReturn(aResponse().withStatus(200).withHeader("Set-Cookie", "_osm_session=" + COOKIE).withBody("<osm/>")));
+        wireMock.getWireMock().register(post(urlEqualTo("/oauth2/token"))
+                .willReturn(aResponse().withStatus(200).withBody("{}")));
+
+        final HttpClient details = HttpClient.create(URI.create(wireMock.getHttpBaseUrl() + "/api/0.6/user/details").toURL());
+        details.setHeader("Authorization", "Bearer " + TOKEN);
+        try {
+            details.connect();
+        } finally {
+            details.disconnect();
+        }
+        final HttpClient token = HttpClient.create(URI.create(wireMock.getHttpBaseUrl() + "/oauth2/token").toURL(), "POST");
+        token.setHeader("Content-Type", "application/x-www-form-urlencoded");
+        token.setRequestBody(("grant_type=authorization_code&client_id=an-id&client_secret=" + CLIENT_SECRET + "&code=a-code")
+                .getBytes(StandardCharsets.UTF_8));
+        try {
+            token.connect();
+        } finally {
+            token.disconnect();
+        }
+
+        final String log = String.join("\n", logged);
+        assertTrue(log.contains("Authorization=Bearer ...stripped..."), log);
+        assertTrue(log.contains("client_secret=...stripped..."), log);
+        for (String secret : new String[] {TOKEN, COOKIE, CLIENT_SECRET}) {
+            assertFalse(log.contains(secret), () -> "logged: " + secret + "\n" + log);
+        }
+    }
+}
diff --git test/unit/org/openstreetmap/josm/tools/TextUtilsTest.java test/unit/org/openstreetmap/josm/tools/TextUtilsTest.java
new file mode 100644
index 0000000000..96841967d6
--- /dev/null
+++ test/unit/org/openstreetmap/josm/tools/TextUtilsTest.java
@@ -0,0 +1,88 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.tools;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * Unit tests of {@link TextUtils}.
+ */
+class TextUtilsTest {
+
+    /**
+     * Test of {@link TextUtils#wrapLongUrl}.
+     */
+    @Test
+    void testWrapLongUrl() {
+        assertEquals("https:/​/​example.org/​x?a=1&​b=2", TextUtils.wrapLongUrl("https://example.org/x?a=1&b=2"));
+    }
+
+    /**
+     * API keys and tokens in a URL are stripped, as before; other parameters are kept.
+     */
+    @Test
+    void testStripUrl() {
+        assertEquals("https://example.org/{z}/{x}/{y}.png?access_token=...stripped...&style=dark",
+                TextUtils.stripUrl("https://example.org/{z}/{x}/{y}.png?access_token=abc&style=dark"));
+        assertEquals("https://example.org/tiles?apikey=...stripped...&connectId=...stripped...",
+                TextUtils.stripUrl("https://example.org/tiles?apikey=abc&connectId=def"));
+        assertEquals("https://example.org/search?q=Main+Street&postcode=AB1",
+                TextUtils.stripUrl("https://example.org/search?q=Main+Street&postcode=AB1"));
+    }
+
+    /**
+     * The OAuth 2.0 authorization code in the redirect received by Remote Control is stripped.
+     */
+    @Test
+    void testStripUrlAuthorizationCode() {
+        assertEquals("GET /oauth_authorization?code=...stripped...&state=a-state HTTP/1.1",
+                TextUtils.stripUrl("GET /oauth_authorization?code=a-code&state=a-state HTTP/1.1"));
+        assertEquals("GET /oauth_authorization?state=a-state&code=...stripped... HTTP/1.1",
+                TextUtils.stripUrl("GET /oauth_authorization?state=a-state&code=a-code HTTP/1.1"));
+    }
+
+    /**
+     * The credentials of an OAuth 2.0 token request are stripped from its form-encoded body; the other parameters are
+     * kept, among them the grant type, whose value may be {@code refresh_token}.
+     */
+    @Test
+    void testStripUrlFormBody() {
+        assertEquals("grant_type=authorization_code&client_id=an-id&client_secret=...stripped...&redirect_uri=http://x"
+                + "&code=...stripped...&code_verifier=...stripped...",
+                TextUtils.stripUrl("grant_type=authorization_code&client_id=an-id&client_secret=a-secret"
+                + "&redirect_uri=http://x&code=a-code&code_verifier=a-verifier"));
+        assertEquals("grant_type=refresh_token&refresh_token=...stripped...",
+                TextUtils.stripUrl("grant_type=refresh_token&refresh_token=a-refresh-token"));
+        assertEquals("username=someone&password=...stripped...", TextUtils.stripUrl("username=someone&password=secret"));
+    }
+
+    /**
+     * The values of the headers which are credentials are stripped, but for the scheme of an authorization; the
+     * other headers are kept as they are, in the same order.
+     */
+    @Test
+    void testStripHeaders() {
+        final Map<String, String> request = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+        request.put("Accept", "application/xml");
+        request.put("authorization", "Bearer a-token");
+        request.put("Proxy-Authorization", "Basic dXNlcjpwYXNzd29yZA==");
+        request.put("Cookie", "a-cookie=1; other=2");
+        assertEquals("{Accept=application/xml, authorization=Bearer ...stripped..., Cookie=...stripped..., "
+                + "Proxy-Authorization=Basic ...stripped...}", TextUtils.stripHeaders(request).toString());
+
+        final Map<String, List<String>> response = new LinkedHashMap<>();
+        response.put(null, Collections.singletonList("HTTP/1.1 200 OK"));
+        response.put("Set-Cookie", Arrays.asList("_osm_session=a-cookie; path=/; HttpOnly", "other=1"));
+        response.put("Content-Type", Collections.singletonList("application/json"));
+        assertEquals("{null=[HTTP/1.1 200 OK], Set-Cookie=[...stripped..., ...stripped...], Content-Type=[application/json]}",
+                TextUtils.stripHeaders(response).toString());
+    }
+}
