Why would this be vulnerable? Your program accepts connections from arbitrary people (potentially on the whole Internet), and lets them display arbitrary bytes to your terminal. There is only one attack vector here: your terminal itself. If your terminal has a bug that (for example) executes bytes instead of printing them, then the system could be compromised because of this setup.
However, that is unlikely -- in fact, one common technique for verifying that programs aren't totally broken is to pass arbitrary data into them and see if/how they explode. This is called fuzz testing, and if there was such a bug in your terminal when it was fuzz tested, the fuzz test would produce really interesting explosions, rather than just terminal garbage.
Just because something is accessible to the Internet on a port doesn't mean there's a vulnerability. You need an actual exploitable flaw, and in this case, there probably isn't one. (Although one never knows.)
What are you trying to secure? Using Python to listen on a socket isn't going to directly expose you to a vuln unless the Python interpreter has an unknown vuln.
Handling incoming messages is a different matter.
If you're writing to a terminal, does that mean the incoming data is expected to be in a specific format? How are you parsing incoming data? What happens if someone cats /dev/random into your port and leaves the connection open for a nice, long time?
Does the order or content of messages matter?
And so on. There aren't many specifics of the scenario to comment on, so the recommendations will be equally vague. As a start, take a look at OWASP secure coding principles for general concepts (they're applicable even if you're not dealing with HTTP or HTML).
发布评论
评论(2)
为什么这会很脆弱?您的程序接受来自任意人(可能在整个互联网上)的连接,并让他们在您的终端上显示任意字节。这里只有一种攻击媒介:您的终端本身。如果您的终端存在错误(例如)执行字节而不是打印字节,那么系统可能会因为此设置而受到损害。
然而,这不太可能——事实上,验证程序没有完全损坏的一种常见技术是将任意数据传递给它们并查看它们是否/如何爆炸。这称为模糊测试,如果您的终端在进行模糊测试时出现这样的错误,模糊测试会产生真正有趣的爆炸,而不仅仅是终端垃圾。
仅仅因为某个端口可以访问互联网并不意味着存在漏洞。您需要一个实际可利用的缺陷,但在这种情况下,可能不存在。 (尽管人们永远不知道。)
Why would this be vulnerable? Your program accepts connections from arbitrary people (potentially on the whole Internet), and lets them display arbitrary bytes to your terminal. There is only one attack vector here: your terminal itself. If your terminal has a bug that (for example) executes bytes instead of printing them, then the system could be compromised because of this setup.
However, that is unlikely -- in fact, one common technique for verifying that programs aren't totally broken is to pass arbitrary data into them and see if/how they explode. This is called fuzz testing, and if there was such a bug in your terminal when it was fuzz tested, the fuzz test would produce really interesting explosions, rather than just terminal garbage.
Just because something is accessible to the Internet on a port doesn't mean there's a vulnerability. You need an actual exploitable flaw, and in this case, there probably isn't one. (Although one never knows.)
你想保护什么?使用 Python 监听套接字不会直接暴露漏洞,除非 Python 解释器有未知漏洞。
处理传入消息是另一回事。
如果您正在写入终端,这是否意味着传入数据应采用特定格式?您如何解析传入数据?如果有人将 /dev/random 插入您的端口并长时间保持连接打开,会发生什么?
消息的顺序或内容重要吗?
等等。该场景没有太多具体细节可供评论,因此建议也同样模糊。首先,请查看 OWASP 安全编码原则了解一般概念(它们是即使您不处理 HTTP 或 HTML,也适用)。
What are you trying to secure? Using Python to listen on a socket isn't going to directly expose you to a vuln unless the Python interpreter has an unknown vuln.
Handling incoming messages is a different matter.
If you're writing to a terminal, does that mean the incoming data is expected to be in a specific format? How are you parsing incoming data? What happens if someone cats /dev/random into your port and leaves the connection open for a nice, long time?
Does the order or content of messages matter?
And so on. There aren't many specifics of the scenario to comment on, so the recommendations will be equally vague. As a start, take a look at OWASP secure coding principles for general concepts (they're applicable even if you're not dealing with HTTP or HTML).