Hardening against prototype pollution#7
Merged
GrahamCampbell merged 2 commits intomainfrom Apr 24, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens Compose against prototype pollution and inherited-property edge cases by introducing “safe object” utilities, normalizing persisted state, and tightening how services/outputs/commands are resolved across the runtime.
Changes:
- Add
safe-objectutilities (null-prototype registries, own-property checks, safe shallow assign, own-only path lookup). - Normalize local/S3 state on read and enforce reserved component/service id handling in state and component resolution.
- Expand unit tests to cover reserved keys (
__proto__,constructor,prototype), inherited properties, and null-prototype registries.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/safe-object.js | New utilities for null-prototype registries, own checks, safe assignment, and own-only path access. |
| src/state/normalize-state.js | New state normalization to drop reserved component ids and ensure safe component registries. |
| src/state/S3StateStorage.js | Normalize remote state after JSON parse (and on missing key). |
| src/state/LocalStateStorage.js | Normalize local state after file read (and on missing file). |
| src/state/BaseStateStorage.js | Enforce reserved component ids on write; use own-property checks and null-prototype registries for components/outputs. |
| src/configuration/validate.js | Ensure services is an own property; reject reserved service aliases; ignore inherited framework keys. |
| src/cli/Progresses.js | Store progresses in a null-prototype registry and avoid inherited-key lookups. |
| src/Context.js | Store componentCommandsOutcomes in a null-prototype registry. |
| src/ComponentsService.js | Replace Ramda path with own-only lookup; use null-prototype maps; reject reserved aliases; avoid inherited output paths and inherited commands. |
| test/unit/src/utils/safe-object.test.js | New unit tests for safe-object utilities and prototype-pollution cases. |
| test/unit/src/state/normalize-state.test.js | New unit tests for state normalization behavior. |
| test/unit/src/state/S3StateStorage.test.js | Verify normalized components registry and reserved-id stripping on remote state. |
| test/unit/src/state/LocalStateStorage.test.js | New tests for local state normalization / reserved-id stripping. |
| test/unit/src/state/BaseStateStorage.test.js | New tests for reserved-id handling and null-prototype registries in state storage. |
| test/unit/src/configuration/validate.test.js | Add tests for inherited services, inherited framework keys, and reserved aliases. |
| test/unit/src/configuration/read.test.js | Ensure nested unsafe keys are preserved as own data when reading configuration. |
| test/unit/src/components-service.test.js | Add tests for inherited keys/paths/commands and reserved alias handling. |
| test/unit/src/cli/Progresses.test.js | Validate null-prototype progresses registry behavior. |
| test/unit/src/Context.test.js | Ensure output rendering works with null-prototype maps. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
No description provided.