If we suppose that an attacker has a zero-day vulnerability for a major browser, and can exploit this vulnerability. How can a Linux/Ubuntu user secure themselves from downloading malware (like keyloggers or other stuff that can can access to user's OS / escalate privileges) and gain execution a user's system?
If an attacker has a sandbox-bypassing 0day exploit, there is little you can do. The best way of preventing this from happening is having good web-browsing hygiene.
Things you can do to limit your risk of infection:
- Run an Add blocker (advertisements are often targetted as they're widespread across different websites)
- Run no-script plugin (to prevent unwanted redirection)
- Don't visit dodgy websites, but only visit reputable websites
- Try to use SSL as much as possible
If the exploits triggers an arbitrary code execution, you are compromised as soon as you read the trapped webpage. Since it's a 0-day there are no strict way of detecting the attack, or avoiding it (no patch, no known signature, no known behaviours)
The possible ways to avoid this would be:
- running an resident anti-virus that can monitor your computer behaviour and block suspicious activities (large download, large upload, disk access to certain "critical" path, ...) using heuristics to block these
- running your browser from a sandboxed environment so that if something gets compromised it's the sandbox
- applying a least privilege policy, so that your browser runs with the lowest level of privileges it needs
- having the rest of your system up-to-date to avoid attack chains that could ultimately lead to having a full control over the system