Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security issue with TalkerHttpLogger: Bearer tokens #150

Closed
JPFrancoia opened this issue Oct 7, 2023 · 3 comments · Fixed by #322
Closed

Security issue with TalkerHttpLogger: Bearer tokens #150

JPFrancoia opened this issue Oct 7, 2023 · 3 comments · Fixed by #322
Labels
addons Related to addons/bridge packages like dio_logger and bloc_logger enhancement New feature or request talker_http_logger Related to talker_http_logger package

Comments

@JPFrancoia
Copy link

Hi,

I was playing with Talker and the talker_http_logger package.

My app uses a piece of code very similar to the example:

import 'package:http_interceptor/http_interceptor.dart';
import 'package:talker_http_logger/talker_http_logger.dart';

void main() async {
  final client = InterceptedClient.build(interceptors: [
    TalkerHttpLogger(),
  ]);

  await client.get("https://google.com".toUri());
}

Looking at the http logger:

class TalkerHttpLogger extends InterceptorContract {
  TalkerHttpLogger({Talker? talker}) {
    _talker = talker ?? Talker();
  }

  late Talker _talker;

  @override
  Future<BaseRequest> interceptRequest({
    required BaseRequest request,
  }) async {
    final message = '${request.url}';
    _talker.logTyped(HttpRequestLog(message, request: request));
    return request;
  }

  @override
  Future<BaseResponse> interceptResponse({
    required BaseResponse response,
  }) async {
    final message = '${response.request?.url}';
    _talker.logTyped(HttpResponseLog(message, response: response));
    return response;
  }
}

The logger simply writes the request to the logs, including the headers, without obfuscating anything. This is a problem when the headers contain stuff like Bearer 1234.... These sensitive values are written in clear to the logs.

I would suggest obfuscating these specific fields by default, with maybe a flag to disable the obfuscation.

Cheers

@Frezyx Frezyx added enhancement New feature or request good first issue Good for newcomers labels Nov 8, 2023
@Frezyx
Copy link
Owner

Frezyx commented Nov 8, 2023

Hello @JPFrancoia !
Great idea 🦄

I fully support the implementation of such functionality in the package.
Does you have any representation or reference of this feature ?

@Frezyx Frezyx added addons Related to addons/bridge packages like dio_logger and bloc_logger and removed good first issue Good for newcomers labels Nov 17, 2024
@Frezyx Frezyx added the talker_http_logger Related to talker_http_logger package label Nov 20, 2024
@Frezyx
Copy link
Owner

Frezyx commented Jan 12, 2025

To fix this issue we can copy logic from this PR
#315

@JPFrancoia
Copy link
Author

Ah yeah, I stopped using the http logger a while ago and I now use the gRPC one. I have implemented some token/payload obfuscation here: https://github.com/JPFrancoia/talker_grpc_logger/blob/master/lib/src/talker_grpc_logger_base.dart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addons Related to addons/bridge packages like dio_logger and bloc_logger enhancement New feature or request talker_http_logger Related to talker_http_logger package
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants