SECURITY-839 backport SECURITY-834 and SECURITY-836 to 2.2.x

JIRA: https://issues.jboss.org/browse/SECURITY-839
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1104976
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1086795