Reverse Engineering Dark Souls 3 Networking
timleonard.uk
timleonard.uk
As someone who spends a lot of time writing and structuring regular old REST APIs, it's a lot of fun to see an approach to API design that is rooted in the foreign convention of game design, even if the implementation language is in the ballpark of ones I use.
Interestingly, once you get past the authentication, the reliable UDP implementation, and into the "meat" of the behavior, it's the same sort of call-response stuff that anybody else is doing, with the same sort of fairly basic little payloads. The "special sauce" is all the components getting to that point - and the fact you're getting binary data and not JSON or something. Not the most exciting thing, if you're a game developer.
Sometimes I wonder what somebody who paid as thorough attention to systems I've worked on would say about them. What would the weird stumbling blocks be? What would the "magic" be that seems to make no sense? ("What are the security holes they find?" goes without saying, but that's feedback I get from our internal pentesters anyway.)
> As our encryption is asymmetric, you may be asking how the client decrypts messages send by the server if it only has a public key. To do this the game exploits an interesting quirk of RSA cryptography, its possible to encrypt with the private key and decrypt with the public key. This is exactly what happens when the server sends the client message. For anyone contemplating doing this though, don’t, it’s terrible for a number of reasons. You can read some of these reasons here, written by someone far more knowledgeable about cryptography than myself.
Great effort reverse engineering the protocol and producing an enjoyable write up.
Isn't it just signing/verifying? I.e. "encryption" with a private key is how RSA is being used to sign, and "decryption" with a public key - used to verify the signature.
It would seem odd, however, that client -> server is encrypted but unsigned whereas server -> client is signed but unencrypted. My guess, for what it’s worth, is that somebody at the company insisted that all comes must be encrypted and so they cobbled this together along with the obfuscation of the public key the author describes.
I was curious to read the reasons. The ones that come to mine are the obvious ones that EC is significantly faster and more secure and that you should only use asymmetric to negotiate a symmetric key exchange (eg ECDH) since symmetric is going to be even faster and suitable for real-time streaming.
You can find it here: https://timleonard.uk/2022/06/02/reverse-engineering-dark-so...
There is a huge interest in the game, with many players still playing it, I had fun for a couple of months for a few hours a week.. but then noticed there was a field in a client you use (nobody uses the official client, they use Runelite, which is an amazing opensource client for OSRS).
I reverse engineered the login protocol, it was a lot of fun. Erlang pattern matching on binaries with Elixir made this incredibly easily and very fun to implement.
This is very important to understand why currently DS3 PC server is closed for half a year now due to cheaters. FromSoftware does a childish attempt at creating a server hence the plague of cheaters. And what they do? They released Elden Ring instead of working to properly create a server. FromSoftware knows how to create console games, but a PC game is outside of their expertise.
They are capable of writing a netcode that is good enough for an environment where it is relatively safe due to the restrictions of the devices it runs on but not for any true open environment. - So they just write bad netcode, that's all.
Servers in FromSoft games are only for matchmaking. The actual gameplay has always been peer to peer. The design of the games mean that making the multiplayer entirely online server based would not work. They're peer to peer because that's the best way to support the hybrid singleplayer / multiplayer design where players drop into and out of your world. Otherwise your world state would need to be consistently synced to the server, which introduces major problems -- in particular, the fact that you would be dealing with lag in a game that you spend mostly singleplayer.
They would have to rework the game design to be able to effectively make the multiplayer run on dedicated servers instead of P2P.
This isn't quite true, they could have on-demand spin up of a "server" and hand off relevant gameplay decisions to it but it would be a ludicrous overcomplication and expensive for one small part of the actual game.
Switching to a rollback system for their peer-peer networking would do a lot to prevent exploits though but would likely be a significant and difficult change with the determinism requirements.
it's a business decision made by real grown up adults. you're being horribly childish yourself.
While the game not being sandboxed creates risks for the consumers (as demonstrated by FROM with Dark Souls 3) and allows people to more easily exploit the game, it also makes modding and often times supporting a game long past its original lifetime possible.
Personally, I would love to have the benefits of sandboxing but I would not want to live without modding and community supported servers. The console market shows us how consumers are abused in an environment where they have no say in what happens to the software that they purchased.
Someone will develop a reasonable, possibly quite open sandboxing technology. That technology goes on to be adopted by one or multiple major publishers. Over the years, anti-cheat and other proprietary detection mechanisms get more and more prevalent within it. Connection to multiplayer servers will no longer be possible without the publisher-provided sandbox. Modding will be more and more restricted until eventually, some form of paid-mods or user-store within the now completely publisher-controlled runtime environment appears.
Call me pessimistic but that's what I gather from my last two decades of gaming with highlights such as Origin scanning your whole machine, DS shadowbanning people, etc.
So typical sandboxing on Linux will never go in the ways of DRM, or give control to the publisher of the software. Your fear will become true, if software starts targetting or even preferring a trusted platform instead of a open platform like the PC we currently have. But this is not fault of a sandboxing technology itself, it's the fault of companies looking to have control over their product and their users.
Unfortunately, I can see future going towards with trusted platforms, where users on non-trusted system will be heavily handicapped, for example netflix not allowing 4k streaming, multiplayer games not allowing you online, or putting you on different servers etc... Valve's linux + proton push may make developers keep targeting the proton WIN32 subset in the future, but we'll see...
Regarding modding, many online games do not allow it even in the current form, requiring you to play offline if the game is modified, or connect to a custom server. By the way, on linux you can easily achieve a sandbox using bwrap https://github.com/containers/bubblewrap