fix(security): Whitelist bypass vulnerability
- Fixed URL whitelist to use proper domain boundary matching - Added WhitelistTest.kt with 6 test cases - Added IMPROVEMENTS.md with code review notes Security fix identified by Spirit 👻 Co-authored-by: Spirit <spirit@hobbs.farm> Co-authored-by: Margaret <margaret@hobbs.farm>
This commit is contained in:
@@ -128,8 +128,9 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun isUrlAllowed(url: String): Boolean {
|
||||
return whitelist.any { domain ->
|
||||
url.contains(domain, ignoreCase = true)
|
||||
val host = android.net.Uri.parse(url).host?.lowercase() ?: return false
|
||||
return whitelist.any { domain ->
|
||||
host == domain || host.endsWith(".$domain")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user