Commit 1810409
committed
fix(security): drop URL substring checks for WXO auth scheme selection
Closes CodeQL alerts #201-204 (py/incomplete-url-substring-sanitization,
high). ``get_authenticator`` chose between the IBM Cloud (IAM) and MCSP
authenticators by testing ``".cloud.ibm.com" in instance_url`` /
``".ibm.com" in instance_url`` against the raw URL string. Because the
check scanned the whole URL, a provider URL whose hostname passes the
existing ``.ibm.com`` allowlist (e.g. ``https://api.sso.ibm.com``) but
whose path, userinfo, query, or fragment contains ``.cloud.ibm.com``
could flip the wrong authenticator:
https://api.sso.ibm.com/.cloud.ibm.com → wrongly IAM
https://cloud.ibm.com@attacker.example/… → wrongly IAM
https://host.ibm.com/?trick=.cloud.ibm.com → wrongly IAM
Scheme selection now drives off ``urlparse(instance_url).hostname``
with ``hostname == "…"`` or ``hostname.endswith(".…")`` — the exact
pattern documented as safe in CodeQL's rule help.
Also tightens the two test assertions flagged by the same rule
(``"cloud.ibm.com" in result.base_url``) to exact URL equality against
the normalised mapper output, and adds a parametrised regression test
covering the five known substring bypass shapes (path / query /
userinfo / fragment smuggling).
No behavioural change for real IBM Cloud / MCSP URLs: all 14
``get_authenticator`` tests and 403 tests across the two touched test
modules pass.1 parent dc5b27e commit 1810409
3 files changed
Lines changed: 35 additions & 5 deletions
File tree
- src/backend
- base/langflow/services/adapters/deployment/watsonx_orchestrate
- tests/unit
- api/v1
- services/deployment
Lines changed: 10 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
126 | 127 | | |
127 | 128 | | |
128 | 129 | | |
129 | | - | |
130 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
131 | 138 | | |
132 | | - | |
| 139 | + | |
133 | 140 | | |
134 | 141 | | |
135 | 142 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1809 | 1809 | | |
1810 | 1810 | | |
1811 | 1811 | | |
1812 | | - | |
| 1812 | + | |
1813 | 1813 | | |
1814 | 1814 | | |
1815 | 1815 | | |
| |||
1832 | 1832 | | |
1833 | 1833 | | |
1834 | 1834 | | |
1835 | | - | |
| 1835 | + | |
1836 | 1836 | | |
1837 | 1837 | | |
1838 | 1838 | | |
| |||
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5165 | 5165 | | |
5166 | 5166 | | |
5167 | 5167 | | |
| 5168 | + | |
| 5169 | + | |
| 5170 | + | |
| 5171 | + | |
| 5172 | + | |
| 5173 | + | |
| 5174 | + | |
| 5175 | + | |
| 5176 | + | |
| 5177 | + | |
| 5178 | + | |
| 5179 | + | |
| 5180 | + | |
| 5181 | + | |
| 5182 | + | |
| 5183 | + | |
| 5184 | + | |
| 5185 | + | |
| 5186 | + | |
| 5187 | + | |
| 5188 | + | |
| 5189 | + | |
| 5190 | + | |
5168 | 5191 | | |
5169 | 5192 | | |
5170 | 5193 | | |
| |||
0 commit comments