zitadel/internal
Tim Möhlmann 7a34697267
fix(oidc): return bad request for base64 errors (#7730)
* fix(oidc): return bad request for base64 errors

We've recently noticed an increased amount of 500: internal server error status returns on zitadel cloud.
The source of these errors appear to be erroneous input in fields that are supposed to be bas64 formatted.

```
time=2024-04-08T14:05:47.600Z level=ERROR msg="request error" oidc_error.parent="ID=OIDC-AhX2u Message=Errors.Internal Parent=(illegal base64 data at input byte 8)" oidc_error.description=Errors.Internal oidc_error.type=server_error status_code=500
```

Within the possible code paths of the token endpoint there are a couple of uses of base64.Encoding.DecodeString of which a returned error was not properly wrapped, but returned as-is.
This causes the oidc error handler to return a 500 with the `OIDC-AhX2u` ID.
We were not able to pinpoint the exact errors that are happening to any one call of `DecodeString`.

This fix wraps all errors from `DecodeString` so that proper 400: bad request is returned with information about the error. Each wrapper now has an unique error ID, so that logs will contain the source of the error as well.

This bug was reported internally by the ops team.

* catch op.ErrInvalidRefreshToken

(cherry picked from commit c8e0b30e17)
2024-04-09 14:02:28 +02:00
..
actions feat: support whole config as env (#6336) 2024-02-16 16:04:42 +00:00
activity fix: get orgID when missing on trigger logs (#7555) 2024-03-14 08:49:10 +00:00
admin/repository/eventsourcing fix(setup): init projections (#7194) 2024-01-25 17:28:20 +01:00
api fix(oidc): return bad request for base64 errors (#7730) 2024-04-09 14:02:28 +02:00
auth/repository chore: use pgx v5 (#7577) 2024-03-27 15:48:22 +02:00
auth_request/repository refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
authz fix: check error before using token (#7664) 2024-03-28 12:19:03 +00:00
command fix(oidc): return bad request for base64 errors (#7730) 2024-04-09 14:02:28 +02:00
config refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
crypto fix(crypto): check for nil client secret (#7729) 2024-04-09 08:44:52 +02:00
database chore: use pgx v5 (#7577) 2024-03-27 15:48:22 +02:00
domain fix(oidc): return bad request for base64 errors (#7730) 2024-04-09 14:02:28 +02:00
eventstore chore: use pgx v5 (#7577) 2024-03-27 15:48:22 +02:00
feature feat(oidc): token exchange impersonation (#7516) 2024-03-20 10:18:46 +00:00
form refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
i18n refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
iam refactor: cleanup unused code (#7130) 2024-01-02 14:26:31 +00:00
id chore(Makefile): add go generate target (#6944) 2023-11-22 10:56:43 +00:00
idp fix: use configured binding on SAML IDPs and make sure CSP doesn't block POST binding (#7341) 2024-02-05 14:45:15 +00:00
integration feat: add user v2 pw change required information on query (#7603) 2024-03-28 06:21:21 +00:00
logstore perf: project quotas and usages (#6441) 2023-09-15 16:58:45 +02:00
migration fix(setup): init projections (#7194) 2024-01-25 17:28:20 +01:00
net perf: project quotas and usages (#6441) 2023-09-15 16:58:45 +02:00
notification fix: properly handle otp sms challenge notification in session api (#7653) 2024-03-27 19:48:14 +02:00
org refactor: cleanup unused code (#7130) 2024-01-02 14:26:31 +00:00
project refactor: cleanup unused code (#7130) 2024-01-02 14:26:31 +00:00
protoc merge main into next 2023-10-19 12:34:00 +02:00
qrcode docs(legal): Updated agreements and policies v2 (#3823) 2022-06-15 08:30:58 +02:00
query feat: add user v2 pw change required information on query (#7603) 2024-03-28 06:21:21 +00:00
renderer fix(login): (re)allow HTML in custom login texts (#7575) 2024-03-15 16:29:10 +01:00
repository docs(oidc): token exchange guide (#7625) 2024-03-26 06:28:17 +00:00
static fix(crypto): check for nil client secret (#7729) 2024-04-09 08:44:52 +02:00
statik chore: initial version of a devcontainer (#6352) 2023-08-15 10:49:05 +02:00
telemetry refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
test feat: protos refactoring 2021-03-09 10:30:11 +01:00
user feat: add user v2 pw change required information on query (#7603) 2024-03-28 06:21:21 +00:00
view/repository chore: use pgx v5 (#7577) 2024-03-27 15:48:22 +02:00
webauthn refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
zerrors refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00