TMA-WEBSPHERE-5.4.1
Ensure that all appropriate EJB methods are protected
Deskripsi
Access to the EJB methods should be protected appropriately using roles in deployment descriptor or annotations. Audit: every META-INF/ejb-jar.xml under shared/apps, <server>/apps and <server>/dropins (exploded only, plus .war/.ear-less unzip lookups are not attempted) must contain <method-permission>. Passes when no descriptor is found. EJBs protected with @RolesAllowed/@PermitAll/@DenyAll must be reviewed manually.
Cara pemeriksaan
Metode audit: Perintah shell
bad=0; n=0; nl='
'
r=""
for b in "${WLP_USER_DIR:-}" /opt/ibm/wlp/usr /opt/IBM/WebSphere/Liberty/usr /opt/ol/wlp/usr /usr/local/wlp/usr; do
[ -n "$b" ] && [ -d "$b/servers" ] || continue
for s in "$b"/servers/*/; do [ -f "${s}server.xml" ] && r="$r$s$nl"; done
done
[ -f /config/server.xml ] && r="$r/config/$nl"
strip(){ awk 'BEGIN{RS="<!--"} NR==1{printf "%s",$0; next} {i=index($0,"-->"); if(i) printf "%s",substr($0,i+3)}'; }
gather(){ s=$1; { cat "${s}server.xml" "${s}"configDropins/defaults/*.xml "${s}"configDropins/overrides/*.xml; } 2>/dev/null | strip
for loc in $(cat "${s}server.xml" "${s}"configDropins/defaults/*.xml "${s}"configDropins/overrides/*.xml 2>/dev/null | strip | tr '\r\n\t' ' ' | grep -oE '<include[[:space:]][^>]*>' | sed -n 's/.*location[[:space:]]*=[[:space:]]*"\([^"]*\)".*/\1/p'); do
case $loc in http*) continue;; esac; loc=$(printf '%s' "$loc" | sed "s#\${server.config.dir}/*##"); case $loc in /*) f=$loc;; *) f=$s$loc;; esac
[ -f "$f" ] && strip < "$f"; done; }
tag(){ printf '%s\n' "$X" | grep -oE "<$1([[:space:]][^>]*)?>"; }
chk(){ t=$(tag "$1"); if [ -z "$t" ]; then [ "$5" = na ] && return 0; [ "$4" = y ] && return 0; return 1; fi
tot=$(printf '%s\n' "$t" | grep -c ''); v=$(printf '%s\n' "$t" | sed -n "s/.*[[:space:]]$2[[:space:]]*=[[:space:]]*[\"']\([^\"']*\)[\"'].*/\1/p"); st=0
[ -n "$v" ] && st=$(printf '%s\n' "$v" | grep -c ''); case " config httpSession webAppSecurity jwtSso webContainer httpDispatcher applicationMonitor sslDefault httpOptions ltpa mpMetrics samesite transportLayer authenticationLayer attributeLayer " in *" $1 "*) [ "$st" -gt 0 ] && tot=$st;; esac; ok=$3; neg=n; case $ok in '!'*) neg=y; ok=${ok#!};; esac
if [ "$st" -gt 0 ]; then m=$(printf '%s\n' "$v" | grep -ciE "^($ok)\$"); if [ "$neg" = n ]; then [ "$m" -eq "$st" ] || return 1; else [ "$m" -eq 0 ] || return 1; fi; fi
[ "$st" -lt "$tot" ] && [ "$4" != y ] && return 1; return 0; }
descs(){ u=${s%servers/*/}; find "$u"shared/apps "${s}apps" "${s}dropins" -type f -path "*$1" 2>/dev/null; }
wars(){ u=${s%servers/*/}; find "$u"shared/apps "${s}apps" "${s}dropins" -type f -name '*.war' 2>/dev/null; }
appchk(){ # suffix guard-regex required-regex
for f in $(descs "$1"); do C=$(cat "$f"); printf '%s' "$C" | grep -qE "$2" && { printf '%s' "$C" | grep -qE "$3" || return 1; }; done
if command -v unzip >/dev/null 2>&1; then for w in $(wars); do C=$(unzip -p "$w" "$1" 2>/dev/null); [ -n "$C" ] && printf '%s' "$C" | grep -qE "$2" && { printf '%s' "$C" | grep -qE "$3" || return 1; }; done; fi; return 0; }
IFS="$nl"; for s in $r; do n=$((n+1)); X=$(gather "$s" | tr '\r\n\t' ' ' | tr -s ' ')
appchk META-INF/ejb-jar.xml "<enterprise-beans" "<method-permission" || bad=1
done; unset IFS; [ "$n" -gt 0 ] || exit 1; [ "$bad" -eq 0 ] && echo compliant || echo noncompliant- Output yang diharapkan
compliant
Cara perbaikan
Metode perbaikan: Panduan atau patch infrastruktur
Set <method-permission> elements in the ejb-jar.xml deployment descriptor file of each application or use annotations. Example using method-permission: <method-permission> <role-name>teller</role-name> <method> <ejb-name>myEJB1</ejb-name> <method-name>getBalance</method-name> </method> </method-permission> Example using annotations: @RolesAllowed("teller") public class myEJB1 { public void getBalance () {...} ... }
Properti
- Sistem operasi
- Apa saja
- Tag
- websphereejbauthorization
- Referensi
- CIS IBM WebSphere Liberty Benchmark v1.0.0 - 5.4.1 Ensure that all appropriate EJB methods are protected
Periksa host ini
Jalankan ini pada mesin yang diizinkan untuk Anda audit. Pemindaian bersifat hanya baca.
tmaegis scan --target websphere