Skip to content

Commit 405aea7

Browse files
errorcodeQQerrorcodeQQ
authored andcommitted
feat: Add extreme sandbox to aggressively neuter blocked plugins
1 parent 94789d1 commit 405aea7

2 files changed

Lines changed: 34 additions & 2 deletions

File tree

CSGuard/src/main/kotlin/com/csguard/CSGuardPlugin.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,15 @@ try {
113113
private fun sanitizeVideoClickActions() {
114114
val actions = VideoClickActionHolder.allVideoClickActions
115115
val maliciousActionClasses = setOf(
116-
"com.cncverse.browser.BrowserAdAction",
116+
"com.MaliciousPlugin.browser.BrowserAdAction",
117117
"com.ad.RedirectAction",
118118
)
119119
var removed = 0
120120
val toRemove = mutableListOf<VideoClickAction>()
121121
for (action in actions.toList()) {
122122
val srcPlugin = try { action.sourcePlugin ?: "" } catch (_: Throwable) { "" }
123123
val className = action::class.java.name
124-
if (srcPlugin.contains("CNCVerse", ignoreCase = true) ||
124+
if (srcPlugin.contains("MaliciousPlugin", ignoreCase = true) ||
125125
srcPlugin.contains("AdNetwork", ignoreCase = true) ||
126126
className in maliciousActionClasses
127127
) {

CSGuard/src/main/kotlin/com/csguard/GuardedContext.kt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,38 @@ class GuardedContext(
6969

7070
private fun shortUrl(url: String): String =
7171
if (url.length > 80) url.take(77) + "..." else url
72+
73+
private val isStrictlyBlocked: Boolean
74+
get() = providerName != null && (policy.blockAllUnknown || AllowlistStore.blockedProviders().contains(providerName))
75+
76+
override fun getSystemService(name: String): Any? {
77+
if (isStrictlyBlocked) {
78+
when (name) {
79+
Context.WINDOW_SERVICE,
80+
Context.CLIPBOARD_SERVICE,
81+
Context.NOTIFICATION_SERVICE,
82+
Context.VIBRATOR_SERVICE,
83+
Context.LOCATION_SERVICE,
84+
Context.AUDIO_SERVICE -> return null
85+
}
86+
}
87+
return super.getSystemService(name)
88+
}
89+
90+
override fun sendBroadcast(intent: Intent?) {
91+
if (isStrictlyBlocked) return
92+
super.sendBroadcast(intent)
93+
}
94+
95+
override fun startService(service: Intent?): android.content.ComponentName? {
96+
if (isStrictlyBlocked) return null
97+
return super.startService(service)
98+
}
99+
100+
override fun bindService(service: Intent, conn: android.content.ServiceConnection, flags: Int): Boolean {
101+
if (isStrictlyBlocked) return false
102+
return super.bindService(service, conn, flags)
103+
}
72104
}
73105

74106
data class GuardPolicy(

0 commit comments

Comments
 (0)