Repository navigation
fix(api): harden external input validation #21
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
Open
0xbigapple
wants to merge
17
commits into
release_v4.8.3
Choose a base branch
from
fix/api-input-hardening
base: release_v4.8.3
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
8152529
fix(api): reject a contract query for a malformed address
0xbigapple 3a49b86
fix(api): bound json numbers before conversion
0xbigapple 7bca8a9
fix(api): answer an unusable address identically on every endpoint
0xbigapple 045f929
fix(shielded): bound the shielded TRC-20 description counts
0xbigapple 8e90727
fix(shielded): report unusable shielded trigger input as a validation…
0xbigapple de5ae92
fix(api): bound Base58 rendering of oversized address fields
0xbigapple 6142b03
fix(api): surface input-validation messages past the error sanitizer
0xbigapple ba54931
fix(api): simplify address and Permission_id error handling
0xbigapple d4d27d0
refactor(api): rename hex to isHex in getAddress
0xbigapple fd04799
fix(shielded): drop the mint receive description count check
0xbigapple d51dd27
Merge remote-tracking branch 'upstream/release_v4.8.3' into fix/api-i…
0xbigapple d986c51
fix(shielded): bound mint and burn receive description counts
0xbigapple 8734a39
fix(http): keep Base58 rendering for genesis addresses
0xbigapple 437200f
refactor(http): simplify genesis address comment
0xbigapple 75939ea
refactor(shielded): spell out transfer count checks
0xbigapple f7a1fa3
Merge remote-tracking branch 'upstream/release_v4.8.3' into fix/api-i…
0xbigapple 15a379f
Merge remote-tracking branch 'upstream/release_v4.8.3' into fix/api-i…
0xbigapple File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
15 changes: 15 additions & 0 deletions
15
common/src/main/java/org/tron/core/exception/InvalidHttpParameterException.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package org.tron.core.exception; | ||
|
|
||
| import java.security.InvalidParameterException; | ||
|
|
||
| public class InvalidHttpParameterException extends InvalidParameterException { | ||
|
|
||
| public InvalidHttpParameterException(String message) { | ||
| super(message); | ||
| } | ||
|
|
||
| public InvalidHttpParameterException(String message, Throwable cause) { | ||
| super(message); | ||
| initCause(cause); | ||
| } | ||
| } |
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: This catch-all around
Util.getAddressroutes every exception into the debug-level client-error path, butgetAddressalready converts all expected request-input failures toInvalidHttpParameterException(blank/missing address, malformed hex or base58, unparseable JSON body). Anything else that escapes it — e.g. anIOExceptionfrom reading the POST body ingetRequestValue, or an unexpected runtime failure — is a genuine server-side fault, andUtil.processErrornow hides it at DEBUG while reporting it to the client as a parameter error. Per the newUtil.processServerErrorcontract, server-side failures should be logged at ERROR. CatchInvalidHttpParameterExceptionin the parsing block and let unexpected exceptions hit the second catch (single try block with both catch clauses).GetRewardServlethas the identical issue.Prompt for AI agents