MohGovIL / hamagen-react-native

Israel's Ministry of Health's COVID-19 Exposure Prevention App
https://health.gov.il/
MIT License
508 stars 153 forks source link

Client-Side CSRF/SSRF from gisweb.azureedge.net response #274

Open emanuelb opened 4 years ago

emanuelb commented 4 years ago

Here the response of request to https://gisweb.azureedge.net/get_config.json?r=${Math.random()} (assumed json is returned) will be stored in configUrls variable, which some data in the json configUrls.data[env] is passed to downloadAndVerifySigning function, that will use without verification and whitelisted domains as input to axios.get('${url}.sign?r=${Math.random()}' command. https://github.com/MohGovIL/hamagen-react-native/blob/c981f8f229208e69fa0d2d29a95a2f3117fe7295/src/config/config.ts#L15-L16 https://github.com/MohGovIL/hamagen-react-native/blob/4c13112f1ed803e6c5d1bdfacc473d0f65ee2268/src/services/SigningService.ts#L5-L7

thus the server can return any URIs (not just https:// but http:// as well, for any domain, such as: http://192.168.1.1 to attack local network resources, such as routers, etc...)

the .sign?r= addition is easily bypassed/ignored by adding # or &x= to the url (it will be part of the hash or additional parameter)

fix: implement white-list in the application of allowed hosts (only in https:// protocol) that can be used in the request for the signed data.