2011-04-23 26 views
3

我正在做一个内嵌TCL解释器的系统的安全测试。系统接收来自因特网(HTTP)的输入,解析并传递给可定制的TCL脚本。在一个起毛测试(发送在HTTP头中的二进制垃圾)我注意到在日志中以下错误:做这些TCL错误指示不安全的代码?

TCL error: list element in quotes followed by "{}x" instead of space while executing "foreach header [ XXXXX ] { }"

TCL error: unmatched open quote in list while executing "foreach header [ XXXXX ] {}"

这里XXXXX是返回的HTTP标头的阵列的命令,如由系统解析。对于混淆真实命令感到抱歉,我希望你明白,在供应商被告知有关问题(如果事实证明是一个问题)之前,我不想公布太多的细节。

TCL代码产生的错误是非常简单的:

foreach header [ XXXXX ] { }

据我所知,HTTP分析是TCL之外完成和解析值通过自定义命令(可能是由于TCL扩展实现对TCL做访问)。

所以我的问题是:

  1. 是安全问题和系统,如不足的用户输入验证这些错误搬弄是非的迹象?

  2. 如果是,是否可以通过发送系统特制的请求来利用此条件执行任意TCL语句,code injection attack

  3. 有没有“安全的TCL编码实践”文件?我找不到任何东西。

回答

7

你问这对comp.lang.tcl,我答道:

1) Are these error tell-tale signs of security problems with the system, such as insufficient user input validation?

他们在解析代码问题的指示。我猜 代码假设它可以假设头是一个格式良好的 Tcl列表,你发现它是完全不安全的。消毒是 使用这样的事情:

set listOfWords [regexp -all -inline {\S+} $someString] 

字的结果集合是保证是一个结构良好的 名单,对任意输入字符串。

2) If yes, can this condition be exploited to execute arbitrary TCL statements by sending the system specially crafted request, a kind of http://en.wikipedia.org/wiki/Code_injection attack?

也许不是,除非你把那个列表当作代码来处理。

3) Are there any "Secure TCL coding practices" document? Any other source of information on how to safely handle untrusted data?

最简单的方法是做在一个安全解释解析:

interp create -safe parsingInterp 
parsingInterp eval { make the procedures } 
parsingInterp eval [list doTheParse $stringToParse] 

请注意,我们也保证构建列表(例如,那些出 list,和许多其他的命令之外)是安全的。那就是:

eval [list $a $b $c] 

正是一样:

$a $b $c 

这是真正的无论是在那些变量。

+2

让我们看看他是否可以在另一个地方问同样的问题。 – 2011-04-23 20:47:14