-
Notifications
You must be signed in to change notification settings - Fork 129
fix(guard): fix url decoding actor id + token #3357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(guard): fix url decoding actor id + token #3357
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
3 Skipped Deployments
|
Pull Request ReviewThis PR adds URL decoding for actor IDs and tokens in the path-based routing system for both Rust (guard) and TypeScript (RivetKit). The implementation is solid and includes comprehensive test coverage. ✅ Strengths
🔍 Code Quality ObservationsRust implementation (engine/packages/guard/src/routing/mod.rs:211-220):
TypeScript implementation (rivetkit-typescript/packages/rivetkit/src/manager/gateway.ts:399-428):
💡 Minor Suggestions
// URL-decode both actor_id and token since clients may encode special characters
let decoded_aid = urlencoding::decode(aid).ok()?.to_string();
🎯 Potential ConcernsNone identified. This is a straightforward bug fix that addresses a real issue with URL-encoded actor IDs and tokens. 📋 Test CoverageBoth Rust and TypeScript test suites now include:
The test coverage is thorough and validates the behavior comprehensively. 🏁 RecommendationApproved ✅ This is a well-implemented fix with excellent test coverage. The code follows repository conventions (as outlined in CLAUDE.md), handles errors properly, and maintains consistency between the Rust and TypeScript implementations. The minor suggestions above are optional improvements that don't block merging. |
ce1b9a9 to
cd3979e
Compare
fff5961 to
ded7c11
Compare
Pull Request ReviewSummaryThis PR fixes URL decoding issues in actor ID and token parsing for both Rust (guard package) and TypeScript (rivetkit) implementations. The changes ensure that URL-encoded characters in actor IDs and tokens are properly decoded before use. Positive Aspects ✓
Potential Issues & Concerns1. Critical: Double Decoding Risk 🔴The most significant concern is the potential for double URL decoding. This is a common security and correctness issue:
Recommendation:
2. Security: No Validation After Decoding
|
ded7c11 to
e787601
Compare
cd3979e to
0eb4caf
Compare
Pull Request ReviewThis PR fixes URL decoding for actor IDs and tokens in the gateway routing logic. The changes look solid overall with good test coverage. Here are my findings: ✅ Positive Points
🔍 Code Quality ObservationsRust Implementation (
TypeScript Implementation (
🤔 Potential Concerns & Questions
🔒 Security Considerations
⚡ Performance Considerations
📝 Minor Suggestions
🎯 VerdictApproved with minor suggestions ✅ The code correctly fixes the URL decoding issue for actor IDs and tokens. The implementation is clean, well-tested, and follows the repository's conventions. The only questions are around edge cases and documentation of intentional behavior regarding the remaining path not being decoded. Action Items (Optional)
|
Code Review: URL Decoding for Actor ID and TokenThank you for this PR! This is a well-implemented fix that addresses URL encoding issues in actor path parsing. Here's my comprehensive review: ✅ Strengths1. Correct Implementation
2. Excellent Error HandlingRust ( let decoded_aid = urlencoding::decode(aid).ok()?.to_string();
TypeScript ( try {
actorId = decodeURIComponent(rawActorId);
token = decodeURIComponent(rawToken);
} catch (e) {
return null; // Invalid URL encoding
}
3. Comprehensive Test CoverageBoth implementations have excellent test coverage:
4. Proper Dependency Management
5. Security Considerations
🔍 Observations & Considerations1. Remaining Path Not Decoded (Intentional?)The Rust (mod.rs:115): assert_eq\!(result.remaining_path, "/api%20endpoint/test%2Fpath");Analysis: This appears intentional and correct:
✅ This is correct behavior 2. Token Validation DeferredFrom // NOTE: Token validation implemented in EEThe decoded token string is not validated for format/content at the guard level. This is consistent with the existing architecture where token validation happens in the Enterprise Edition. 3. Error ObservabilityCurrently, invalid URL encoding silently returns let decoded_aid = match urlencoding::decode(aid) {
Ok(s) => s.to_string(),
Err(e) => {
tracing::debug\!(actor_segment = aid, "failed to decode actor_id");
return None;
}
};However, this is not critical since:
🎯 Best Practices Compliance✅ Follows CLAUDE.md Guidelines:
✅ Security Best Practices:
📊 Performance ConsiderationsImpact: Minimal
🔒 Security Assessment✅ No Security Concerns IdentifiedAttack Surface Analysis:
📝 Suggestions (Optional)1. Consider Adding Tracing for Failed Decodes (Optional)For better observability during debugging: let decoded_aid = urlencoding::decode(aid).map_err(|e| {
tracing::debug\!(?aid, "invalid url encoding in actor_id");
e
}).ok()?.to_string();Priority: Low - Nice to have but not critical 2. Document Encoding Behavior (Optional)Consider adding a comment in the function documentation about encoding expectations: /// Parse actor routing information from path
/// Matches patterns:
/// - /gateway/{actor_id}/{...path}
/// - /gateway/{actor_id}@{token}/{...path}
///
/// Note: actor_id and token are URL-decoded. remaining_path is NOT decoded
/// to allow proper forwarding to downstream services.
Priority: Low - The behavior is clear from tests ✅ Final Verdict: LGTMThis PR is well-implemented, thoroughly tested, and ready to merge. The changes:
No blocking issues identified. The optional suggestions above are minor enhancements that could be addressed in future PRs if desired. Test Results Expected:
Great work on fixing this issue! 🎉 |
0eb4caf to
d1c6bfd
Compare
e787601 to
cd9a7ee
Compare
PR Review: fix(guard): fix url decoding actor id + tokenSummaryThis PR addresses URL decoding issues for actor IDs and tokens in path-based routing, ensuring that URL-encoded characters are properly handled in both the Rust guard package and TypeScript rivetkit implementation. Code Quality ✅Rust Implementation (
|
Code Review - PR #3357: fix(guard): fix url decoding actor id + tokenSummaryThis PR adds URL decoding for actor IDs and tokens in the path-based routing system. The implementation is consistent across both Rust (guard) and TypeScript (rivetkit) codebases. ✅ Strengths
🔍 Potential Issues & Concerns1. Security: Double Decoding Vulnerability
|
d1c6bfd to
1cee2e1
Compare
cd9a7ee to
f74136c
Compare
PR Review: URL Decoding Fix for Actor ID and TokenSummaryThis PR adds URL decoding support for actor IDs and tokens in the gateway path parsing logic. The implementation is solid and addresses a real issue where URL-encoded characters in actor IDs and tokens would not be properly decoded before use. ✅ Strengths
🔍 Code Quality ObservationsRust Implementation (
|
f74136c to
67ab859
Compare
1cee2e1 to
8499e1e
Compare
PR Review: fix(guard): fix url decoding actor id + tokenSummaryThis PR adds URL decoding for actor IDs and tokens in path-based routing, ensuring that URL-encoded characters in these path segments are properly decoded before being used. The fix is implemented consistently in both the Rust guard package and the TypeScript RivetKit gateway. Positive Observations1. Comprehensive Implementation
2. Excellent Test Coverage
3. Proper Dependency Management
Issues and Suggestions1. Security Concern: Missing Validation After Decoding (HIGH PRIORITY)The code decodes actor IDs and tokens but doesn't validate the decoded values. This could allow problematic characters that were URL-encoded to bypass validation: In // URL-decode both actor_id and token
let decoded_aid = urlencoding::decode(aid).ok()?.to_string();
let decoded_tok = urlencoding::decode(tok).ok()?.to_string();
(decoded_aid, Some(decoded_tok))Recommendation: Add validation after decoding to ensure actor IDs and tokens contain only allowed characters. Consider:
Example validation: // After decoding
let decoded_aid = urlencoding::decode(aid).ok()?.to_string();
if decoded_aid.is_empty() || decoded_aid.chars().any(|c| c.is_control()) {
return None;
}2. Inconsistent Encoding Handling for Remaining PathThe code now URL-decodes the actor_id and token, but NOT the remaining path. This is inconsistent and potentially confusing: In let remaining_path = if remaining_base.is_empty() || !remaining_base.starts_with('/') {
format!("/{}{}", remaining_base, query_string)
} else {
format!("{}{}", remaining_base, query_string)
};Question for consideration: Should the remaining path segments also be URL-decoded? This depends on your routing architecture:
Recommendation: Add a comment explaining why 3. Test Coverage Gap: @ Symbol in Actor IDThe tests don't verify what happens when an actor ID itself contains a
However, since the code splits on the FIRST
Recommendation: Add a test case for this scenario and document the expected behavior. If 4. Minor: Decoding Before Splitting vs AfterCurrent implementation splits on
This is likely correct (treating the literal
If this is the intended behavior, it's fine. Just ensure it's documented. 5. Code Organization: Repeated Decoding LogicIn the Rust code, the decoding logic is duplicated in two branches (lines 212-213 and line 218). Consider extracting to a helper: fn decode_path_segment(segment: &str) -> Option<String> {
urlencoding::decode(segment).ok().map(|s| s.to_string())
}Then use: let decoded_aid = decode_path_segment(aid)?;
let decoded_tok = decode_path_segment(tok)?;This improves maintainability and ensures consistent handling. Performance ConsiderationsThe let decoded_aid = urlencoding::decode(aid).ok()?;
// Only convert to String when needed
(decoded_aid.to_string(), Some(decoded_tok.to_string()))This is a micro-optimization but could be beneficial if this code path is hit frequently. Testing RecommendationsConsider adding these additional test cases:
DocumentationConsider adding comments to explain:
ConclusionOverall Assessment: This is a solid fix that addresses a real bug. The implementation is consistent across Rust and TypeScript, with good test coverage. Blockers:
Recommendations:
Nice to Have:
Let me know if you'd like me to elaborate on any of these points or provide code examples for the recommended changes! |
PR Review: fix(guard): fix url decoding actor id + tokenSummaryThis PR adds URL decoding support for actor IDs and tokens in path-based routing for both the Rust guard package and TypeScript RivetKit. The implementation is generally solid with good test coverage. Strengths
Potential Issues and Recommendations1. Security: Path Traversal Risk (Priority: Medium) After URL decoding, there is no validation that decoded values don't contain path traversal sequences. An attacker could send /gateway/actor%2F..%2Fadmin@token/endpoint which decodes to actor/../admin Recommendation: Add validation after decoding to reject actor_ids containing path separators, parent directory references (..), or null bytes. 2. Inconsistent Decoding (Priority: High) The implementation only decodes actor_id and token segments, but NOT the remaining_path. The test at line 111-116 shows encoded characters in remaining path are preserved. Is this intentional? Recommendation: Add a comment explaining why remaining_path is intentionally not decoded, or verify that downstream handlers properly decode it. 3. Token Validation Missing (Priority: Low) Similar to actor_id, the decoded token should also be validated. The comment mentions Token validation implemented in EE - ensure the EE implementation validates decoded tokens. 4. Test Gap: Invalid Characters After Decoding (Priority: Low) The test suite validates invalid URL encoding but doesn't test for dangerous characters that appear after successful decoding. Recommend adding tests for path traversal attempts and null bytes. Testing Recommendations
Performance ConsiderationsURL decoding is computationally inexpensive with efficient string operations and no blocking operations. Performance impact is negligible. VerdictApprove with minor recommendations The core functionality is solid and well-tested. Main concerns:
The fix correctly addresses the original issue of URL-encoded actor IDs and tokens not being decoded properly. Suggested Action Items
|
Merge activity
|

No description provided.