T09 · Insecure Skill Coding Practices
- Location
scripts/build-rpm.sh:6- Finding
RPM SPEC Injection Through Unvalidated Package Metadata
- Content
View full analysis
"$SPEC_FILE" << EOF Name: ${PACKAGE_NAME} Version: ${VERSION} Release: ${RELEASE}%{?dist} Summary: ${PACKAGE_NAME} application License: MIT URL: https://example.com/${PACKAGE_NAME} Source0: %{name}-%{version}.tar.gz BuildRequires: gcc make Requires: glibc %description ${PACKAGE_NAME} - Built from source automatically %prep %setup -q %build %configure make %{?_smp_mflags} %install make install DESTDIR=%{buildroot} %files %defattr(-,root,root,-) %{_bindir}/${PACKAGE_NAME} %changelog * $(date +%a\ %b\ %d\ %Y) ${RPM_BUILDER_NAME} - ${VERSION}-${RELEASE} - Initial package build EOF log_info "SPEC file generated" echo "$SPEC_FILE" } ``` ```bash build_rpm() { local SPEC_FILE="$1" log_info "Building RPM package..." rpmbuild -ba "$SPEC_FILE" 2>&1 | tee "$RPM_BUILD_DIR/BUILDLOGS/${PACKAGE_NAME}-${VERSION}.log" ``` ### Technical Analysis The script accepts `PACKAGE_NAME`, `VERSION`, and `RELEASE` from positional arguments and `RPM_BUILDER_NAME` from the environment without validating their syntax. These values are inserted directly into an RPM SPEC file. Shell quoting around `cat > "$SPEC_FILE"` protects the destination filename from shell word ...[truncated 1820 chars]- Remediation
View remediation
