Closed
Conversation
To mitigate potential Server-Side Request Forgery (SSRF) vulnerabilities, the JSON-LD document loader no longer fetches remote contexts from the network. It now exclusively uses a predefined set of preloaded local contexts. An attempt to load an unknown context URL will result in a JsonLdError. BREAKING CHANGE: Remote JSON-LD context fetching has been disabled. All contexts must be preloaded locally.
Enables the loading of remote JSON-LD contexts while adding a security layer to prevent Server-Side Request Forgery (SSRF) attacks. The document loader now resolves the hostname of the context URL and blocks any request targeting a loopback or private IP address. This change also fixes a TypeError in the caching mechanism by ensuring the cache key is a hashable JSON string. Tests have been added to verify the new security behavior.
Adds unit tests for the JSON-LD document loader to verify the new Server-Side Request Forgery (SSRF) protection mechanism. The tests cover the following scenarios: - Attempts to load contexts from loopback and private network addresses are blocked. - Unresolvable hostnames are handled correctly. - Loading from a public address is permitted.
The StrEnum class, used for string-based enumerations, was officially added to the standard library in Python 3.11. To ensure compatibility with older Python versions (>=3.10), this commit adds the backports-strenum dependency.
The @context field was previously included in the model's serialized output, which is not ideal for nested objects. This change introduces a mechanism to exclude the @context field from the model dump by default. The loader now injects a special flag to identify the top-level object, allowing for more precise control over the final JSON-LD structure. Additionally, this commit ensures the Note model is correctly processed during the model rebuild phase.
Member
Author
|
I changing approach |
Closed
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.
THIS IS BREAKING CHANGE!
resolve #9
Changes
Restrictions
Currently, this implementation is incomplete, and the following features cannot be used properly.
Implemented
apmodel.load()Todo
serialize_by_alias=Trueto all modelsActivityPubModelbased models to the loading mechanismExample
Do you want try this? try this code!