Commit 2a42b83
committed
Defensive fixes: non-Hash raw_info, filter state/nonce
Two small hardening tweaks from the security review pass:
1. Controller guards against a non-Hash extra.raw_info from the
OIDC strategy. A well-behaved omniauth_openid_connect run
always gives us a Hash, but a custom or buggy strategy could
set it to a String, nil, Array, etc — and the old code went
straight to .to_h.transform_keys and crashed the callback
action with a 500. Now we collapse anything non-Hash to {}
and rebuild sub/email from the top-level auth hash, which is
exactly the fallback path the next two lines were already
doing for the normal case. Covered by a new request spec.
2. filter_parameters now also masks 'state' and 'nonce'. They
aren't secrets in the bearer-token sense, but they are
session-bound single-use values and leaking them into logs
serves no purpose. Industry default is to treat them as
opaque. Updated the security spec to assert on both keys.
The agent review also flagged the failure_message log line as
a potential PII leak, but closer reading of Devise's
OmniauthCallbacksController#failure_message shows it returns a
short humanized error code (error_reason || error ||
error.type) — not the raw OAuth error_description from the IdP.
Leaving that log alone.1 parent a87c359 commit 2a42b83
4 files changed
Lines changed: 44 additions & 11 deletions
File tree
- app/controllers/active_admin/oidc/devise
- lib/activeadmin/oidc
- spec
- requests
Lines changed: 9 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
24 | 30 | | |
25 | 31 | | |
26 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
61 | 66 | | |
62 | | - | |
| 67 | + | |
63 | 68 | | |
64 | 69 | | |
65 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
130 | 152 | | |
131 | 153 | | |
132 | 154 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
0 commit comments