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

[Enhancement] Restrict information available in ResponseError #1737

Open
davidlago opened this issue Jan 17, 2024 · 1 comment
Open

[Enhancement] Restrict information available in ResponseError #1737

davidlago opened this issue Jan 17, 2024 · 1 comment
Labels
enhancement New feature or request triaged

Comments

@davidlago
Copy link

davidlago commented Jan 17, 2024

The security of the OpenSearch Dashboard could be hardened by restricting the information available in a ResponseError. Indeed, it appears that the OpenSearch Dashboards does not perform a filtering in the ResponseError fields, especially Authorizations headers.

This is currently not a security issue in OpenSearch as the Exceptions are not logged, but could further harden the security of the product and prevent any future misusage.

class ResponseError<TResponse = Record<string, any>, TContext = Context> extends OpenSearchClientError {
  name: string;
  message: string;
  meta: ApiResponse<TResponse, TContext>;
  body: TResponse;
  statusCode: number;
  headers: Record<string, any>;
  constructor(meta: ApiResponse);
}

The following test shows that no logging is performed but that the exception class may contain too much information:

it('Check that sensitive headers are filtered out', async () => {
     const { server: innerServer, createRouter } = await server.setup(setupDeps);
     const router = createRouter('/');

     router.get({ path: '/', validate: false }, (context, req, res) => {
       const error = new Error('unauthorized');
       return res.custom({
         statusCode: 401,
         body: error,
         headers: {"Authorization": "secret-value"}
       });
     });

     await server.start();

     const result = await supertest(innerServer.listener).get('/').expect(401);

     expect(result.body.message).toBe('unauthorized');
     expect(loggingSystemMock.collect(logger).error).toHaveLength(0);
     //expect(result.headers).toBe({}); // <- for the moment, the whole header array is available
});
@davidlago davidlago added enhancement New feature or request untriaged labels Jan 17, 2024
@davidlago davidlago changed the title [Enhancement] Restrict informations available in ResponseError [Enhancement] Restrict information available in ResponseError Jan 17, 2024
@davidlago davidlago transferred this issue from opensearch-project/security-dashboards-plugin Jan 17, 2024
@davidlago davidlago transferred this issue from opensearch-project/security Jan 17, 2024
@stephen-crawford
Copy link
Contributor

[Triage] Hi @davidlago, thanks for filing this issue. This is a good preemptive measure to keep things above board. We can close this issue when the logging has been changed to redact any of the sensitive information from the response and we have tests to show this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triaged
Projects
None yet
Development

No branches or pull requests

2 participants