In practice, self-modification is a special case of arbitrary code execution; it’s just running a program that looks like yourself, with some changes. That means there are two routes to get there: either communicate with the internet (to, eg, pay Amazon EC2 to run the modified program), or use a security vulnerability. In the context of computer security, preventing arbitrary code execution is an extremely well-studied problem. Unfortunately, the outcome of all the study is that it’s really hard, and multiple vulnerabilities are discovered every year with low probability of them ever stopping.
In practice, self-modification is a special case of arbitrary code execution; it’s just running a program that looks like yourself, with some changes. That means there are two routes to get there: either communicate with the internet (to, eg, pay Amazon EC2 to run the modified program), or use a security vulnerability. In the context of computer security, preventing arbitrary code execution is an extremely well-studied problem. Unfortunately, the outcome of all the study is that it’s really hard, and multiple vulnerabilities are discovered every year with low probability of them ever stopping.