How to verify from server that client code hasn't been modified

久未见 提交于 2019-12-06 10:43:05

You can't. You essentially have no way of knowing what code is running on the client, and none of your program logic should rely on treating the client as "trusted". All access control, validation etc should be done on the server (or in both places).

Certain specialist environments (e.g. code embedded on a smart card, or devices such as games consoles whoes OS is designed to only run signed code) give you a bit more of a guarantee because of the increased difficulty of reverse engineering/gaining appropriate control of the device. But even these aren't infallible (look at the iPhone or any console and see how long it took for the devices to be 'cracked' compared with the interest in doing so to give you an idea of the level of security).

You cannot verify that the client was not modified with a client-server architecture.

You should never trust the input from a client unless an authenticated user (login + password match) is talking to you over a secure connection (e.g. SSL).

The client has to just call the logic instead of sending it to the sever.

First thing that comes to mind would be for the client to send both a signature file (within code) and a hash of itself.

But, like you say, it can be spoofed.

If you are trying to relly on the client's authenticity to do stuff on the server: don't! Rethink you logic. If this is just an extra safety measure (go with it).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!