OpenSCAP / openscap

NIST Certified SCAP 1.2 toolkit
https://www.open-scap.org/tools/openscap-base
GNU Lesser General Public License v2.1
1.35k stars 370 forks source link

OpenSCAP could possibly fail to write a verbose message when switching to offline mode #1191

Open jan-cerny opened 6 years ago

jan-cerny commented 6 years ago

We call dI after chroot() but before calling chdir("/").

 openscap-1.2.17/src/OVAL/probes/probe/main.c:253: chroot_call: Calling chroot: "chroot(rootdir)".
16. openscap-1.2.17/src/OVAL/probes/probe/main.c:263: chroot: Calling function "__oscap_dlprintf" after chroot() but before calling chdir("/").
#   261|             * mechanism to control this behaviour in the future.
#   262|             */
#   263|->          dI("Swiching probe to PROBE_OFFLINE_CHROOT mode.");
#   264|            probe.selected_offline_mode = PROBE_OFFLINE_CHROOT;
#   265|        }
evgenyz commented 4 years ago

There is a security-related Covscan error related to this "mid-flight" call.

jan-cerny commented 4 years ago

I believe this was even reported as a part of a past Covscan review.

evgenyz commented 4 years ago

@jan-cerny I remember you fixing this bug, but I can't find the PR. Is it just my imagination?

jan-cerny commented 4 years ago

There was e299045bca54a897d0a47a3c2a88c212bf47f5da which moved this code block to src/OVAL/probes/probe/worker.c But chdir is still called before chroot. So I think it isn't fixed.