zitadel/internal
Tim Möhlmann c8e0b30e17
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
2024-04-09 08:42:59 +02:00
..
actions refactor(fmt): run gci on complete project (#7557) 2024-04-03 10:43:43 +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 08:42:59 +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 08:42:59 +02:00
config feat(crypto): use passwap for machine and app secrets (#7657) 2024-04-05 09:35:49 +00:00
crypto feat(crypto): use passwap for machine and app secrets (#7657) 2024-04-05 09:35:49 +00:00
database fix(db): wrap BeginTx in spans to get acquire metrics (#7689) 2024-04-03 11:48:24 +03:00
domain fix(oidc): return bad request for base64 errors (#7730) 2024-04-09 08:42:59 +02:00
eventstore chore: fix function names in comment (#7723) 2024-04-08 08:15:44 +00: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(idp): do not call userinfo when mapping from ID token is configured (#7696) 2024-04-04 05:41:44 +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 refactor(fmt): run gci on complete project (#7557) 2024-04-03 10:43:43 +00: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(crypto): use passwap for machine and app secrets (#7657) 2024-04-05 09:35:49 +00:00
renderer fix(login): (re)allow HTML in custom login texts (#7575) 2024-03-15 16:29:10 +01:00
repository feat(crypto): use passwap for machine and app secrets (#7657) 2024-04-05 09:35:49 +00:00
static feat(crypto): use passwap for machine and app secrets (#7657) 2024-04-05 09:35:49 +00:00
statik chore: initial version of a devcontainer (#6352) 2023-08-15 10:49:05 +02:00
telemetry refactor(fmt): run gci on complete project (#7557) 2024-04-03 10:43:43 +00:00
test refactor(fmt): run gci on complete project (#7557) 2024-04-03 10:43:43 +00:00
user feat(crypto): use passwap for machine and app secrets (#7657) 2024-04-05 09:35:49 +00:00
view/repository refactor(fmt): run gci on complete project (#7557) 2024-04-03 10:43:43 +00:00
webauthn refactor: rename package errors to zerrors (#7039) 2023-12-08 15:30:55 +01:00
zerrors refactor(fmt): run gci on complete project (#7557) 2024-04-03 10:43:43 +00:00