You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Starting on audit recommendations. The following are implemented
lru_cache on uplc_unflat
Evaluation of scripts can't use more resources than defined in protocol
For submit_tx calls, check requested ExUnits are valid before execution.
Maximum transaction size limits.
Reverted test using Redis
Now sharing sessions between server workers using SQLite database. Sessions are pickled and saved before each call. There is plenty of room for optimisation here but just working towards getting something functioning at the moment.
SlowAPI for rate limiting
Session lifespan / cleanup using contextlib.asynccontextmanager
Audit Recommendations
Critical
3.1.1 Memory Management in Script Evaluation
Unbounded Script Cache in uplc_unflat solved with lru cache. (here)
Unconstrained Script Size: Enforced via enforcing the maximum transaction size. (here)
Session Persistence: Created a SessionManager (here) that is used by a contextlib.asynccontextmanager to periodically cleanup old sessions (here). Session lifespan is determined by environment variables MOCKFROST_MAX_IDLE_TIME, MOCKFROST_MAX_SESSION_LIFESPAN (See here)
State Management Vulnerabilities: There is no explicit limit on Session size, however there is an effective limit by virtue of Sessions having a limited lifespan and the number of requests being rate limited and thus there is a limit to the number of UTxOs that can be added to the internal state before the Session times out.
Medium Severity Findings
UTxO Set Growth: Same as above. UTxO set growth is now effectively capped by a combination of Session lifespan and rate limiting on requests. It would also be trivial to add an additional lower rate limit explicitly on requests that grow the internal state in future. @limiter.limit("3600/day") decorator on any problematic endpoints. For example this commit adds a rate limiting to submission of transactions.
Concurrency Issues. SESSION object is now shared between workers via a sqlite database (here, Sessions are currently just pickled and saved in a database with the default name SESSIONS.db.
Reference Validation.
I don't think UTxO existence needs to be validated as a transaction will simply fail when creating a list of input_utxos (here).
Ownership is currently not checked. Users are free to modify the UTxO set of a session by design. However, there are currently no witness verification during transaction evaluation other than script evaluation.
Potential for reference manipulation attacks. Only if you have managed to steal someone elses SESSION_ID.
Low Severity Findings
Exception Information Exposure. This is not a major problem
Inconsistent Error Handling. I have started moving towards handling errors in a similar way to Blockfrost does for consistency. for example see here and here
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
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.
Starting on audit recommendations. The following are implemented
Reverted test using Redis
Audit Recommendations
Critical
3.1.1 Memory Management in Script Evaluation
uplc_unflatsolved with lru cache. (here)3.1.2 Session Management
contextlib.asynccontextmanagerto periodically cleanup old sessions (here). Session lifespan is determined by environment variables MOCKFROST_MAX_IDLE_TIME, MOCKFROST_MAX_SESSION_LIFESPAN (See here)Medium Severity Findings
@limiter.limit("3600/day")decorator on any problematic endpoints. For example this commit adds a rate limiting to submission of transactions.SESSIONS.db.Low Severity Findings