Skip to content
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

Some errors are not obscured by gRPC server #5857

Closed
SWvheerden opened this issue Oct 23, 2023 · 0 comments · Fixed by #5892
Closed

Some errors are not obscured by gRPC server #5857

SWvheerden opened this issue Oct 23, 2023 · 0 comments · Fixed by #5892
Assignees
Labels
release-blocker Something that needs to be fixed before a release can be made

Comments

@SWvheerden
Copy link
Collaborator

Attackers can get information about the base node via gRPC errors, even when the
user has set the configuration to obscure the errors.
The particular method that fails to obscure the errors is get_new_block_blob,
where the obscure_error_if_true call is missing:

        let new_block = match 
handler.get_new_block(block_template).await {
            Ok(b) => b,
            
Err(CommsInterfaceError::ChainStorageError(ChainStorageError::InvalidAr
guments { message, .. })) => {
                return Err(Status::invalid_argument(message));
            },
            
Err(CommsInterfaceError::ChainStorageError(ChainStorageError::CannotCal
culateNonTipMmr(msg))) => {
                let status = Status::with_details(
                    tonic::Code::FailedPrecondition,
                    msg,
                    Bytes::from_static(b"CannotCalculateNonTipMmr"),
                );
                return Err(status);
            },
            Err(e) => return Err(Status::internal(e.to_string())),
        };

Errors related to the serialization of the blob also will not be obscured:

        let mut header_bytes = Vec::new();
        BorshSerialize::serialize(&header, &mut 
header_bytes).map_err(|err| Status::internal(err.to_string()))?;

There are also other inconsistencies in the usage of the obscure_error_if_true
method. For example, the majority of invalid arguments are not obscured, possible
to let the requester know what they must correct for their request to succeed. But
some, like errors related to the public key serialization in get_shard_key, are
obscured:

        let public_key = PublicKey::from_bytes(&request.public_key)
            .map_err(|e| obscure_error_if_true(report_error_flag, 
Status::invalid_argument(e.to_string())))?;
@SWvheerden SWvheerden added the release-blocker Something that needs to be fixed before a release can be made label Oct 23, 2023
@hansieodendaal hansieodendaal self-assigned this Oct 31, 2023
SWvheerden pushed a commit that referenced this issue Nov 1, 2023
Description
---
Consistently applied `obscure_error_if_true` within
`base_node_grpc_server.rs`

Closes #5857

Motivation and Context
---
See #5857

How Has This Been Tested?
---
Pass existing tests

What process can a PR reviewer use to test or verify this change?
---
Code walk-through

<!-- Checklist -->
<!-- 1. Is the title of your PR in the form that would make nice release
notes? The title, excluding the conventional commit
tag, will be included exactly as is in the CHANGELOG, so please think
about it carefully. -->


Breaking Changes
---

- [x] None
- [ ] Requires data directory on base node to be deleted
- [ ] Requires hard fork
- [ ] Other - Please specify

<!-- Does this include a breaking change? If so, include this line as a
footer -->
<!-- BREAKING CHANGE: Description what the user should do, e.g. delete a
database, resync the chain -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-blocker Something that needs to be fixed before a release can be made
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants