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

Clean up DefaultServerTLSConfig & an unnecessary md5 #990

Merged
merged 5 commits into from
Jul 27, 2021

Conversation

huitseeker
Copy link
Contributor

This impacts the check of the rootsnapshot file: CLI users would have to run the sha256sum command-line utility on it instead of md5sum

@huitseeker huitseeker changed the title Clean up an unnecessary md5 Clean up dead code & an unnecessary md5 Jul 19, 2021
@huitseeker huitseeker force-pushed the security1 branch 3 times, most recently from 3adeb8e to 04fa024 Compare July 19, 2021 14:46
@huitseeker huitseeker force-pushed the security1 branch 3 times, most recently from 115c89c to c17b645 Compare July 19, 2021 15:37
@codecov-commenter
Copy link

codecov-commenter commented Jul 19, 2021

Codecov Report

Merging #990 (a1e2b5b) into master (ce3b61b) will decrease coverage by 0.00%.
The diff coverage is 25.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #990      +/-   ##
==========================================
- Coverage   54.81%   54.81%   -0.01%     
==========================================
  Files         277      277              
  Lines       18548    18548              
==========================================
- Hits        10168    10167       -1     
- Misses       7005     7006       +1     
  Partials     1375     1375              
Flag Coverage Δ
unittests 54.81% <25.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
cmd/bootstrap/transit/cmd/pull.go 11.32% <0.00%> (ø)
engine/execution/state/delta/delta.go 66.66% <ø> (ø)
cmd/bootstrap/transit/cmd/utils.go 30.57% <100.00%> (ø)
cmd/util/ledger/migrations/storage_v4.go 41.56% <0.00%> (-0.61%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ce3b61b...a1e2b5b. Read the comment docs.

@huitseeker
Copy link
Contributor Author

CC @m4ksio for the last commit a1e2b5b which is an SSA violation detected only by the golangci-lint updated in the present PR

@huitseeker
Copy link
Contributor Author

Sister PR at onflow/flow#575 (update will be needed after this merges to update the console print at bootstrap)

Copy link
Contributor

@tarakby tarakby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good to me 👌 but I let the team members involved in the operations side make sure there are no other impacts to these changes.

cmd/bootstrap/transit/cmd/crypto_test.go Outdated Show resolved Hide resolved
@huitseeker huitseeker changed the title Clean up dead code & an unnecessary md5 Clean up DefaultServerTLSConfig & an unnecessary md5 Jul 19, 2021
Copy link
Member

@zhangchiqing zhangchiqing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@@ -89,7 +89,7 @@ func (d Delta) MarshalJSON() ([]byte, error) {
return json.Marshal(m)
}

func (d Delta) UnmarshalJSON(data []byte) error {
func (d *Delta) UnmarshalJSON(data []byte) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why changing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as the commit message indicates, the assigment at line 106 occurs on an immediately-lost copy of the Delta otherwise.

@huitseeker huitseeker force-pushed the security1 branch 2 times, most recently from b821192 to 01d5b47 Compare July 27, 2021 19:21
huitseeker added a commit to huitseeker/flow that referenced this pull request Jul 27, 2021
Do not merge before onflow/flow-go#990 is merged.
This PR updates our file-based user-visible hashes from MD5 to SHA256, a better, yet widely available hash function.

The present PR does the same for the doc, at least in the format of the displayed hashes, rather than actual content: the doc is not updated at every Spork, and the output updated in this PR is here for demonstration only.
@huitseeker
Copy link
Contributor Author

Dependent PR up at onflow/flow#585

@huitseeker huitseeker force-pushed the security1 branch 2 times, most recently from 9055135 to d66600f Compare July 27, 2021 19:42
Copy link
Contributor

@vishalchangrani vishalchangrani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@huitseeker huitseeker force-pushed the security1 branch 2 times, most recently from 780f8cf to b6bfbdd Compare July 27, 2021 20:20
Followup of onflow#944: DefaultServerTLSConfig is unused, but will be in a further PR (onflow#989)
Fix an insecurity, allowing for a TLS [MinVersion == 1.0](https://github.com/golang/go/blob/e3176bbc3ec7ab3889f02432f6fd088c90fc12dd/src/crypto/tls/common.go#L685) (CWE 295)
Use gosec (through golang-ci) to prohibit that error.
The function was using an MD5 for checking, whereas a more secure option like SHA-256 would be preferred.
See https://www.iacr.org/cryptodb/data/paper.php?pubkey=23903 (for example) for the (in-)security.

SHA256 was chosen over Blake2 because there's a widely deployed CLI sha256sum on unix systems, and performance is not an issue here.

Activates gosec G401 to fix such an issue, activates G501, G502, G503, G505 to tie up loose ends on less-secure hash functions..
The error SA4005: ineffective assignment to field Delta.Data was taken by taking a copy of the receiver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants