2011-04-23 252 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