Repository navigation
fix(security): block triggers/views and bound size and execution time in SQL import - #9832
Merged
farion1231 merged 1 commit intoNov 23, 2026
Conversation
YUZHEthefool
force-pushed
the
ao/ccswitch-audit/fix-sql-import-triggers
branch
from
November 22, 2026 03:28
b7cc39c to
773bd43
Compare
Owner
|
已合并,感谢 @YUZHEthefool!导入时拦截 trigger / view 这一项很有价值,叠在最新 main 上验证过,fmt / clippy / 全部测试都通过,会随下一版发布。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human Note / 本人说明
修复历史遗留的 mcp,远程下载侧的安全漏洞与问题
Summary / 概述
Hardens SQL backup and WebDAV/S3 sync import (
src-tauri/src/database/backup.rs) against persistent SQLite trigger/view injection and resource-exhaustion DoS:import_authorizer: DenyCreateTrigger,CreateTempTrigger,DropTrigger,DropTempTrigger,CreateView,CreateTempView,DropView, andDropTempViewwhile executing untrusted SQL. CC Switch's production schema uses no triggers or views; previously, a malicious.sqlbackup or compromised sync snapshot could plant anAFTER INSERT/UPDATEtrigger onproviders/mcp_serversthat survived staging and was copied permanently intocc-switch.db.validate_imported_schema): Verifysqlite_mastercontains zerotriggerorviewobjects before migrating or copying the staging database to the live DB.MAX_SQL_IMPORT_BYTES): Enforce a size cap aligned withsync_protocol::MAX_SYNC_ARTIFACT_BYTES(512 MiB) viaread_sql_file_bounded(metadata pre-check + boundedRead::take) and in-memory length check before executing SQL.progress_handler): Install a SQLiteprogress_handlerdeadline (30s, checked every 10,000 VM opcodes) aroundexecute_batchand detach it immediately afterward, convertingOperationInterruptedinto a localized timeout error so a smallWITH RECURSIVEpayload cannot hang the app or holdsync_mutexindefinitely.Related Issue / 关联 Issue
None
Validation / 验证
cargo fmt --manifest-path src-tauri/Cargo.toml --all -- --check— passedcargo clippy --manifest-path src-tauri/Cargo.toml -- -D warnings— passedcargo test --manifest-path src-tauri/Cargo.toml --lib "database::backup::tests"— 40 passed (includes reproduction tests for persistent trigger/temp-trigger/view rejection, defense-in-depthvalidate_imported_schemacheck,read_sql_file_boundedsize boundary, andWITH RECURSIVEinterruption)Checklist / 检查清单
dump_sqltests and legitimate backup round-trips remain passingcargo clippy -- -D warnings,cargo fmt --check, and tests pass