fix: critical stability, security, and build improvements#29
Open
trbielec wants to merge 4 commits intosupabase:masterfrom
Open
fix: critical stability, security, and build improvements#29trbielec wants to merge 4 commits intosupabase:masterfrom
trbielec wants to merge 4 commits intosupabase:masterfrom
Conversation
- Fix buffer overread in JSONB import (use AMbytes instead of AMstr) - Fix stack overflow vulnerability by adding check_stack_depth() - Fix data corruption on updates via explicit cache invalidation - Fix silent data loss when exporting Text objects in Lists
- Switch from -O0 to -O2 to improve performance - Add AUTOMERGE_STATIC=1 option for deployment on managed PostgreSQL platforms
Adds comprehensive tests covering: - Stale cache invalidation (data corruption fix) - JSONB buffer safety (buffer overread fix) - Text list export correctness (data loss fix) - Numeric precision handling - Commit message type compatibility
- Add comprehensive installation instructions with static/dynamic linking options - Document usage examples and API reference - Add known limitations section - Update .gitignore to exclude PostgreSQL build artifacts (*.o, *.bc, *.so, results/)
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.
Overview
This Pull Request addresses fundamental stability and security vulnerabilities identified during a production readiness audit. It resolves critical memory safety issues, prevents data corruption during updates, enables deployment on managed platforms, and provides complete installation documentation.
Closes: #20, #26, #27
Changes
1. Core Stability & Security
strlen()calls on JSONB strings (which are not null-terminated) withAMbytes(). This prevents potential information disclosure or segfaults duringfrom_jsonb.check_stack_depth()guard clauses to all recursive functions (_object_walk,_array_walk,_autodoc_traverse) to prevent stack overflow attacks via deeply nested inputs.invalidate_flat_cache()logic in all modification paths. This ensures that sequentialUPDATEoperations correctly persist the latest state, fixing a bug where stale binary data was written to disk causing data loss.AM_OBJ_TYPE_TEXThandler inautodoc_to_jsonb, resolving silent data loss when exporting lists containing Text objects.2. Build System & Deployment
-O0(debug) to-O2(production), providing significant performance improvements for serialization-heavy workloads.AUTOMERGE_STATIC=1build flag. This enables static linking oflibautomerge.a, allowing the extension to be deployed on managed PostgreSQL platforms (e.g., AWS RDS, Supabase) where system-level shared libraries cannot be installed.3. Documentation
4. Verification
sql/production_fixes.sqlcontaining tests for stale cache invalidation, buffer safety, text list export, and numeric precision warnings.Impact
These changes are mandatory for production deployment. Without them, the extension is vulnerable to denial-of-service attacks and silent data corruption during standard SQL
UPDATEworkflows. The build updates allow the extension to run on modern managed cloud infrastructure.