DAWN-83 ⁃ p2p authenticate peer on handshake #505
github #505
One of the security enhancements identified as part of #291
ATC, Test Plan
Introduction
This issue adds functionality to eosd and launcher. eosd can now optionally authenticate connecting peers in the p2p network via public key. eosd has a new config file setting called allowed-connection. Valid values for this setting are none, producers, specified, and any. If the setting is not present, it defaults to none. launcher defaults to generating config files with allowed-connection = any. launcher has a new command line option to control this setting: -m. Valid values for this option are identical to those used on the eosd config file.
The repository currently includes a tests/p2p_tests/sync directory with a test.sh script that is run by Travis during every GitHub-initiated build. This script currently tests only the default launcher setting.
Tests
All tests below assume a successful build of the repository. Test commands illustrated below must be run from the top level build directory.
Note: Any or all of the tests described below could be and probably should be automated.
launcher-driven Tests
Verify producer-only authentication (positive validation)
- Run
programs/launcher/launcher -p 3 -n 3 -i now -m producers - Allow
eosdto run for at least 2 minutes. - Run
programs/launcher/launcher -k 2 - Verify each of
tn_data_0/config.ini,tn_data_1/config.ini, andtn_data_2/config.inicontainsallowed-connection = producers. - Verify each of
tn_data_0/stderr.txt,tn_data_1/stderr.txt, andtn_data_2/stderr.txtdoes not containPeer not authenticated. Closing connection.
Verify producer-only authentication (negative validation)
- Run
programs/launcher/launcher -p 2 -n 3 -i now -m producers - Allow
eosdto run for at least 2 minutes. - Run
programs/launcher/launcher -k 2 - Verify each of
tn_data_0/config.ini,tn_data_1/config.ini, andtn_data_2/config.inicontainsallowed-connection = producers. - For the two instances which contain
producer-name =lines inconfig.iniverify either of the correspondingstderr.txts containsPeer localhost:9878 sent a handshake with an unauthorized key: EOS1111111111111111111111111111111114T1Anm.andPeer not authenticated. Closing connection. - For the instance which does not contain
producer-name =lines inconfig.iniverify the correspondingstderr.txtdoes not contain anychain_controller.cpp:235 _push_blocklines and does contain repeatedPeer localhost:9876 sent a handshake with an unauthorized key: EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV.lines.
Verify specified authentication
- Run
programs/launcher/launcher -p 3 -n 3 -i now -m specified - Allow
eosdto run for at least 2 minutes. - Run
programs/launcher/launcher -k 2 - Verify each of
tn_data_0/config.ini,tn_data_1/config.ini, andtn_data_2/config.inicontainsallowed-connection = specified, and entries forpeer-key =andpeer-private-key =. - Verify each of
tn_data_0/stderr.txt,tn_data_1/stderr.txt, andtn_data_2/stderr.txtdoes not containPeer not authenticated. Closing connection.
Verify none authentication
- Run
programs/launcher/launcher -p 3 -n 3 -i now -m none - Allow
eosdto run for at least 2 minutes. - Run
programs/launcher/launcher -k 2 - Verify each of
tn_data_0/config.ini,tn_data_1/config.ini, andtn_data_2/config.inidoes not contain anyallowed-connection =lines. - Verify each of
tn_data_0/stderr.txt,tn_data_1/stderr.txt, andtn_data_2/stderr.txtcontainsPeer not authenticated. Closing connection.
Manually Configured Tests
Verify producer and specified authentication
- Run
programs/launcher/launcher -p 2 -n 3 -i now -m producers -m specified - Run
programs/launcher/launcher -k 2 - Run
programs/eosc/eosc create keythree times. - In a text editor in
tn_data_0/config.ini, change the linepeer-key = "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"to include the first public key generated in the preceding step by pasting the value between the double quotes, overwriting the existing value. Be sure to preserve the double quotes. - In
tn_data_0/config.iniadd a secondpeer-key = ""line containing the second public key generated in the step above. - In
tn_data_0/config.ini, change the linepeer-private-key = ["EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV","5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"]to include the third key pair generated in the step above by pasting first the public key between the first pair of double quotes and second the private key between the second pair of double quotes. - In a text editor in
tn_data_1/config.ini, change the linepeer-key = "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"to include the first public key generated in the step above. - In
tn_data_1/config.ini, add a secondpeer-key = ""line containing the third public key generated in the step above. - In
tn_data_1/config.ini, change the linepeer-private-key = ["EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV","5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"]to include the second key pair generated in the step above. - In a text editor in
tn_data_2/config.ini, change the linepeer-key = "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"to include the second public key generated in the step above. - In
tn_data_2/config.ini, add a secondpeer-key = ""line containing the third public key generated in the step above. - In
tn_data_2/config.ini, change the linepeer-private-key = ["EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV","5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"]to include the first key pair generated in the step above.
#* The distribution of keys to config files described above is summarized in the following table: #* ||config.ini||peer-key||peer-private-key||
|----|----|----| |tn_data_0|1 ^st^ and 2 ^nd^|3 ^rd^| |tn_data_1|1 ^st^ and 3 ^rd^|2 ^nd^| |tn_data_2|2 ^nd^ and 3 ^rd^|1 ^st^|
- Run
programs/eosd/eosd --skip-transaction-signatures --data-dir tn_data_0 > tn_data_0/stdout.txt 2> tn_data_0/stderr.txt & - Run
programs/eosd/eosd --skip-transaction-signatures --data-dir tn_data_1 > tn_data_1/stdout.txt 2> tn_data_1/stderr.txt & - Run
programs/eosd/eosd --skip-transaction-signatures --data-dir tn_data_2 > tn_data_2/stdout.txt 2> tn_data_2/stderr.txt & - Allow
eosdto run for at least 2 minutes. - Run
pkill eosd - Verify each of
tn_data_0/stderr.txt,tn_data_1/stderr.txt, andtn_data_2/stderr.txtdoes not containPeer not authenticated. Closing connection.
┆Attachments: config.ini | config.ini | config.ini
➤ Kevin Heifner commented:
[~jonathan.giszczak] [~phil.mesnier] It seems to me this is out of scope for STAT but it is what Jonathan is currently working on. Should we stop work on this and move to something in scope of STAT?
➤ Phil Mesnier commented:
Jonathan is working on this now because Dan specifically directed him to do so. He is nearly done anyway.
➤ Kevin Heifner commented:
[~jonathan.giszczak] What is your estimate for completion, in terms of story points?
➤ Jonathan Giszczak commented:
All issues addressed. Merge conflicts addressed. All automated tests pass. Ready for peer review and merging.
➤ Kevin Heifner commented:
[~matias.romeo] Why did you mark this as blocked?
➤ Matias Romeo commented:
My bad, It was unintentional! I can't move it back to where it was!
➤ Corey Lederer commented:
No problem [~matias.romeo]. I'll move it back.
➤ Corey Lederer commented:
Placing this back in "Code Review" after is was marked as blocked by accident.
➤ Bezwada Satyapravin commented:
The ATC is very descriptive but it is not clear to me if I should use the launcher to start nodes locally or on testnet. Please advise.
➤ Jonathan Giszczak commented:
The instructions were written for a local testnet, since the daemons will be started and stopped a lot. No need to interfere with the operation of the testnet.
➤ Bezwada Satyapravin commented:
Following commands don't work:
MacBook01:build pravin$ programs/launcher/launcher p 3 n 3 i now m none unrecognized connection mode: none
MacBook01:build pravin$ programs/launcher/launcher -p 2 n 3 i now m producer m specified unrecognized connection mode: producer
➤ Bezwada Satyapravin commented:
Jonathan Giszczak, [Nov 17, 2017 at 8:41:41 PM]: With two notes: reverse priority of producer and peer-private keys.
Please attach the three config.ini files.
And the other note...
non-producing node is not sending the correct authorization key.
➤ Dhanesh Valappil commented:
Can you please update ATC for 21 nodes?
➤ Jonathan Giszczak commented:
The ATC requires a "broken" configuration to verify functionality, and so should be executed as written on local nodes.
➤ Andrianto Lie commented:
Fail for the fourth test case.
andrianto@MacbookPro build ((HEAD detached at STAT-2017-11-27)) $ programs/launcher/launcher -p 3 -n 3 -i now -m none unrecognized connection mode: none
➤ Andrianto Lie commented:
The other test cases pass
➤ Jonathan Giszczak commented:
Launcher enhanced to support the remaining test case.
Verified by QA.
➤ Corey Lederer commented:
Moving to finished, this was moved to closed-withdrawn by mistake.