Gate Address are invertible
somanayr opened this issue ยท 21 comments
Gate addresses are invertible and predictable. It looks like this is done for performance reasons, but it's also a security issue, since a player who knows your gate address can discover your location, even if you have an iris.
I put together a webapp to showcase the issue here: https://sgcraft-scanner-web.herokuapp.com/
A fix would be to encrypt the addresses with the world seed as the secret key. If you'd like, I'm happy to submit a PR for this.
I've looked into this a little more. Format-preserving encryption, with a key derived from the world seed, appears to be the way to go. Of course, that assumes the world seed is secret.
Let me know if you want me to put this together.
But this is exactly canon. In the series they could use the gate address to calculate the position of the planet/stargate .
I have personally written programs using computercraft to map all gate locations. While it is THEORETICALLY possible, it is impractical. At a dialing rate of one address per 30 seconds, it would take YEARS to map even a fraction of the addresses.
edit: Maths, there are 525,600 minutes in a year. At 2 addresses per minute, you can test 1,051,200 per year. There are a 3 quadrillion chunks (3,515,625,000,000) in a standard 30 million x 30 million block world. It would take 3,344,392 years to map every chunk at a dialing rate of 2 addresses per minute.
lol You don't need to dial to find out if a gate exists at an address.
You can check about 1 address per second with the energyToDial() function
I confess I went at my math incorrectly on one point. Instead of counting chunks, I should have counted addressable gates, which is 38^7 for intra-dimensional gates, or 38^9 for all gates. There are two primary ways to design such a dialing program.
Incremental dialing would lead to having to test the entire system, regardless of world size, necessitating all intradimentional gate addresses (114,415,582,592 addresses; 3,628 years of dailling at 1/second).
Selective dialing would require you to produce a list, via some method like the above app, which would lead to a dialing program in excess of 16mb. Last I knew, ComputerCraft has a maximum program size of 2mb, though there is no technical limit on the number of separate programs it can store.
Needless to say, this is an extreme amount of effort to put into a project to locate a single needle in a very large haystack. If it ever became a mainstream problem, it would also be easy to overcome by simply dismantling a gate when not in use, and using proxy-bases.
Or you make it easier and just code the address logic into your minecraft computer and it just converts the coords to addresses which means you don't have to store 16mb.
It's actually a concern since you don't need to dial to know if a gate is at the location, you just need to check for energy cost. Since there's no cooldown on such check, you scan excessively fast and can kill the server along the way.
Something to add, and connect to this (even though this is a pretty old issue-thread), stargates actually only function within x= -2239472 to +2239472, and same for z, which is limiting for sure.
What i suggest is generating addresses on the fly. When a new gate is placed, the address is randomly generated and put into a cache, optionally along with the position of the stargate base, to allow for easier looking up of addresses.
Not only would this make it impossible to link addresses to coordinates via math, it also allows more than one stargate per chunk if anyone wants that, and it allows people to place stargates where ever they want, even if its at x:20 million and z:20 million.
Not sure what to do about the Dimension-digits, i guess they could also be randomly assigned as soon as the first gate is placed in that dimension.
I have not been experiencing any issues playing about 2.2 million blocks away from 0,0 for both x and z, so 3 million blocks away from 0,0 in total.
Additionally, this limit removal is just an added benefit ontop of solving the problem of the addresses being reversible. Effectively solving two issues in one go; i dont see whats wrong with that.