Architecture #6356
closed
User story #6589: Improve Rudder security in 3.1: Inventory signature and security, SELinux compliance
Inventory endpoint should validate agent signature
Added by Benoît PECCATTE over 9 years ago.
Updated over 9 years ago.
Category:
Web - Nodes & inventories
Description
The inventory endpoint should check that:
- the signature is valid
- the signature matches the key contained in the inventory
- the key matches the one currently in the ldap if there is one
- Category changed from 26 to Web - Nodes & inventories
Script to check signature:
#!/bin/bash
# To allow Rudder to provide its own version of openssl
export PATH=/opt/rudder/bin:$PATH
if openssl -h 2> /dev/null
then
true
else
echo "ERROR: openssl binary is missing !"
exit 1
fi
# the file to verify
FILE="$1"
if [ ! -e "${FILE}" ]
then
echo "Cannot verify: The file ${FILE} doesn't exist"
exit 2
fi
# Signature of this file
SIGNATURE="${FILE}.sign"
if [ ! -e "${SIGNATURE}" ]
then
echo "Cannot verify: The file ${SIGNATURE} doesn't exist"
exit 2
fi
# the public key to use for verification
PUBKEY="$2"
if [ ! -e "${PUBKEY}" ]
then
echo "Cannot verify: The file ${PUBKEY} doesn't exist"
exit 2
fi
# extract data from signature
if [ $(head -n1 "${SIGNATURE}") != "header=rudder-signature-v1" ]
then
echo "Not a valid signature file"
exit 3
fi
SIGN_HEX=$(sed -ne '/digest=/s/digest=//p' "${SIGNATURE}")
HASH=$(sed -ne '/algorithm=/s/algorithm=//p' "${SIGNATURE}")
# create binary signature file
SIGN=$(mktemp)
echo -ne $(echo "${SIGN_HEX}" | tr -d '[:space:]' | sed 's/../\\x&/g') > "${SIGN}"
# openssl command only read public keys in X509/pkcs8 format
PUBKEY8=$(mktemp)
openssl rsa -RSAPublicKey_in -in "${PUBKEY}" -pubout -out "${PUBKEY8}" 2> /dev/null
openssl dgst "-${HASH}" -verify "${PUBKEY8}" -signature "${SIGN}" < "${FILE}"
RET=$?
rm -f ${PUBKEY8} ${SIGN}
exit ${RET}
- Status changed from New to In progress
- Assignee set to Vincent MEMBRÉ
- Status changed from In progress to Pending technical review
- Assignee changed from Vincent MEMBRÉ to François ARMAND
- Pull Request set to https://github.com/Normation/ldap-inventory/pull/62
- Status changed from Pending technical review to Pending release
- % Done changed from 40 to 100
- Status changed from Pending release to 12
THis was pushed to Normation repo on branch ust_6356/endpoint_must_check_inventory_digest by mistake and is still in technical review
- Status changed from 12 to Pending technical review
- Status changed from Pending technical review to Pending release
- % Done changed from 60 to 100
- Parent task changed from #6363 to #6589
- Related to Architecture #6502: Older versions of Rudder should ignore the signature file added
- Status changed from Pending release to Released
This bug has been fixed in Rudder 3.1.0~beta1 which were released today.
- Has duplicate User story #6250: Per-Host inventory upload keys / access restrictions added
Also available in: Atom
PDF