Commit d6a8962
fix(auth): allow same-host loopback requests through trusted-proxy path
nginx-on-the-same-box reverse proxies arrive with socket.remoteAddress 127.0.0.1
but carry a non-local Host header and standard forwarding headers. The previous
loopback guard in authorizeTrustedProxy rejected all loopback sources unconditionally,
breaking this legitimate same-host proxy pattern.
Fix: permit loopback addresses through the trusted-proxy header-validation path
when the request appears proxied (non-local-ish Host + forwarding context present).
Plain loopback connections and requests that spoof a non-local Host without
forwarding context are still rejected as trusted_proxy_loopback_source.
The token fallback for direct node connections (isLocalDirectRequest path) is
unchanged — it operates before the trusted-proxy path and handles the openclaw-node
use-case where a node connects directly to the gateway on the same host.
Update tests to reflect correct behavior:
- loopback + non-local host + forwarding headers => trusted-proxy auth succeeds
- loopback + non-local host + forwarding headers + missing user => trusted_proxy_user_missing
- loopback + local host + any forwarding context => trusted_proxy_loopback_source
- direct loopback + valid token => ok (token method)
- direct loopback + wrong token => token_mismatch (not loopback_source)1 parent 4c4346a commit d6a8962
2 files changed
Lines changed: 42 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
829 | 829 | | |
830 | 830 | | |
831 | 831 | | |
832 | | - | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
833 | 836 | | |
834 | 837 | | |
835 | 838 | | |
| |||
849 | 852 | | |
850 | 853 | | |
851 | 854 | | |
852 | | - | |
| 855 | + | |
853 | 856 | | |
854 | 857 | | |
855 | 858 | | |
| |||
1078 | 1081 | | |
1079 | 1082 | | |
1080 | 1083 | | |
1081 | | - | |
1082 | | - | |
1083 | | - | |
1084 | | - | |
1085 | | - | |
1086 | | - | |
1087 | | - | |
1088 | | - | |
1089 | | - | |
1090 | | - | |
1091 | | - | |
1092 | | - | |
1093 | | - | |
1094 | | - | |
1095 | 1084 | | |
1096 | 1085 | | |
1097 | 1086 | | |
| |||
1104 | 1093 | | |
1105 | 1094 | | |
1106 | 1095 | | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
1107 | 1113 | | |
1108 | 1114 | | |
1109 | 1115 | | |
| |||
1194 | 1200 | | |
1195 | 1201 | | |
1196 | 1202 | | |
1197 | | - | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
1198 | 1207 | | |
1199 | 1208 | | |
1200 | 1209 | | |
1201 | 1210 | | |
1202 | 1211 | | |
1203 | | - | |
1204 | | - | |
| 1212 | + | |
| 1213 | + | |
1205 | 1214 | | |
1206 | 1215 | | |
1207 | | - | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
1208 | 1219 | | |
1209 | 1220 | | |
1210 | 1221 | | |
1211 | 1222 | | |
1212 | 1223 | | |
1213 | | - | |
1214 | | - | |
| 1224 | + | |
| 1225 | + | |
1215 | 1226 | | |
1216 | 1227 | | |
1217 | 1228 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
158 | | - | |
159 | | - | |
| 158 | + | |
| 159 | + | |
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
| |||
293 | 293 | | |
294 | 294 | | |
295 | 295 | | |
296 | | - | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
297 | 303 | | |
298 | 304 | | |
299 | 305 | | |
| |||
0 commit comments