-
Notifications
You must be signed in to change notification settings - Fork 707
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A certificate containing a CRL URI that points to an extremely large file causes the server to crash with an out of memory exception. A config option (CRLSizeLimit) has been added to check and make sure that the requested CRL does not exceed the size specified by CRLSizeLimit. The default size limit is 512KB. This will prevent a malicious intent to crash server by pointing to a CRL that is very large. See [FAB-3026] for more information Change-Id: Ibbb0506faecf29b9a9c0a361c2ff701c9945a973 Signed-off-by: Saad Karim <[email protected]>
- Loading branch information
Saad Karim
committed
Jul 27, 2017
1 parent
8a883fa
commit f54aaf2
Showing
12 changed files
with
186 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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,58 @@ | ||
#!/bin/bash | ||
checkMsg() { | ||
awk -v rc=-1 -v m="$1" '$0~m {rc=0} ; {print}; END {exit rc}' | ||
} | ||
rm -rf /tmp/oom/ | ||
RC=0 | ||
httpPort=3755 | ||
export CA_CFG_PATH=/tmp/oom | ||
export FABRIC_CA_CLIENT_HOME=/tmp/oom/admin | ||
FABRIC_CA="$GOPATH/src/github.com/hyperledger/fabric-ca" | ||
SCRIPTDIR="$FABRIC_CA/scripts/fvt" | ||
. $SCRIPTDIR/fabric-ca_utils | ||
mkdir -p /FVT/crl/ | ||
cp $GOPATH/src/github.com/hyperledger/fabric-ca/testdata/crl.pem /FVT/crl/crl.pem | ||
$SCRIPTDIR/utils/pki -f newcert -p admin -t ec -l 256 -n '/C=US/CN=admin/ST=North Carolina/O=Hyperledger/OU=Fabric/CN=admin/' -x <<EOF | ||
127.0.0.2 | ||
admin.fabric.raleigh.ibm.com | ||
[email protected] | ||
Y | ||
EOF | ||
|
||
# Start the default server and check to see if CRL retrieval works if size limit is appropriate | ||
# However, register will fail because we used a 'hacked' enrollment certificate | ||
$SCRIPTDIR/fabric-ca_setup.sh -I -X -S -D | ||
enroll | ||
admin_keyfile="$(find /tmp/oom/admin/msp/keystore -type f)" | ||
admin_certfile="/tmp/oom/admin/msp/signcerts/cert.pem" | ||
hacker_admin_keyfile="/root/adminkey.pem" | ||
hacker_admin_certfile="/root/admincert.pem" | ||
cp $hacker_admin_keyfile $admin_keyfile | ||
cp $hacker_admin_certfile $admin_certfile | ||
cd / | ||
python -m SimpleHTTPServer $httpPort & | ||
pollServer httpserver 127.0.0.1 3755 10 | ||
register admin user1 2>&1 | checkMsg "Error: Error response from server was: Authorization failure" | ||
test $? -ne 0 && ErrorMsg "Failed to return correct error" | ||
|
||
# Lower the CRL size limit on server and check to see that server does not continue to proceed with retrieving CRL list | ||
export FABRIC_CA_SERVER_CRLSIZELIMIT=10 | ||
cd $GOPATH/src/github.com/hyperledger/fabric-ca | ||
$SCRIPTDIR/fabric-ca_setup.sh -K | ||
$SCRIPTDIR/fabric-ca_setup.sh -S -D -X > /tmp/log.txt 2>&1 | ||
enroll admin2 adminpw2 | ||
admin_keyfile="$(find /tmp/oom/admin/msp/keystore -type f)" | ||
admin_certfile="/tmp/oom/admin/msp/signcerts/cert.pem" | ||
hacker_admin_keyfile="/root/adminkey.pem" | ||
hacker_admin_certfile="/root/admincert.pem" | ||
cp $hacker_admin_keyfile $admin_keyfile | ||
cp $hacker_admin_certfile $admin_certfile | ||
register admin user2 client bank_a "" /tmp/oom/admin2 2>&1 | checkMsg "Error: Error response from server was: Authorization failure" | ||
test $? -ne 0 && ErrorMsg "Failed to return correct error" | ||
grep "failed to fetch CRL: Error reading CRL with max buffer size of 10: Size of requested data is too large" /tmp/log.txt &> /dev/null | ||
if [ $? != 0 ]; then | ||
ErrorMsg "Client authentication failed for other reason than CRL size" | ||
fi | ||
CleanUp $RC | ||
exit $RC |
This file contains 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 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,12 @@ | ||
-----BEGIN X509 CRL----- | ||
MIIBxTCBrgIBATANBgkqhkiG9w0BAQsFADBrMRMwEQYKCZImiZPyLGQBGRYDb3Jn | ||
MRcwFQYKCZImiZPyLGQBGRYHY2lsb2dvbjELMAkGA1UEBhMCVVMxEDAOBgNVBAoT | ||
B0NJTG9nb24xHDAaBgNVBAMTE0NJTG9nb24gU2lsdmVyIENBIDEXDTE3MDcyMDA4 | ||
NDcwNFoXDTE3MDgxOTA4NDcwNFqgDzANMAsGA1UdFAQEAgIWJTANBgkqhkiG9w0B | ||
AQsFAAOCAQEAqvzbH1bkrk/mfPAzZEIODN6RMTLe+xQvfZNMAyuY+1ZTXVLq7DjZ | ||
Ya+wYcw99R4Uw6238ET37CnYVBvSt5MFFM4sWF/fPtnLFjlHG4T8l2ie7GjTihzG | ||
ckaG1tfa6DxpdK2a7lQxu9ITobpZvxs5oUDw0YEl+D5bjYOcdZCAh+A2Kf1MJugL | ||
ylL9U7B4rC+MljcPar8Akf9FCQQardnhB/piMhnzqE164OEHhWLgwuL2BUJIyYTq | ||
c25kJ6a1aioX6ifFK53r6NqkVJFo0563zv+6UFA6FWL932kRYQI59kld/rHzc5ZC | ||
MkOd81zvNXrRP+zOPw0qmFhyuBS7qB1R8g== | ||
-----END X509 CRL----- |
This file contains 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 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 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