Skip to content

Commit e65486b

Browse files
committed
fix: MariaDB false positives in WP database scan + heuristic index.php FPs
- Use cmd.Output() instead of CombinedOutput() so MariaDB deprecation warnings on stderr don't appear as injected content in posts/options - Filter remaining warning lines from stdout (belt and suspenders) - Skip standard anti-directory-listing index.php files (<120 bytes, "Silence is golden") from HEURISTIC_RECENT_PHP detection
1 parent fee7e50 commit e65486b

3 files changed

Lines changed: 32 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to the Defensia Agent.
44

5+
## v1.4.48
6+
- **fix: MariaDB deprecation warning causing false positive malware findings**`CombinedOutput()` mixed stderr warnings ("Deprecated program name") into query results, triggering `WP_DB_INJECTED_POST`, `WP_DB_INJECTED_OPTION`, and `WP_DB_ROGUE_ADMIN` on every WordPress site using MariaDB. Now uses `Output()` (stdout only) and filters any remaining warning lines.
7+
- **fix: false positive HEURISTIC_RECENT_PHP on plugin index.php files** — standard anti-directory-listing files (`<?php // Silence is golden`) in plugin asset directories are now skipped.
8+
59
## v1.4.47
610
- **fix: custom scan paths ending in `/` were silently ignored** — a trailing separator makes `filepath.Glob` return zero matches *and* a nil error, so a path like `/home/*/web/*/public_html/` never got scanned and never reported an error. Patterns are now trimmed before matching, and blank entries are skipped instead of resolving to `.` or `/` (which made the scanner walk the whole filesystem).
711
- **HestiaCP / VestaCP support**`/home/*/web/*/public_html` is now detected automatically, no custom path needed. The vhost directory is the domain, so each web root is reported with its domain.

internal/malware/heuristic.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,22 @@ func CheckRecentPHP(path string, maxAgeHours int) *HeuristicFinding {
132132
return nil
133133
}
134134

135+
// Skip standard WordPress/plugin anti-directory-listing index.php files
136+
// (typically "<?php // Silence is golden" or empty). These are created
137+
// by plugin updates and are not malicious.
138+
if strings.HasSuffix(path, "/index.php") {
139+
if data, err := os.ReadFile(path); err == nil && len(data) < 120 {
140+
content := strings.TrimSpace(string(data))
141+
if content == "" ||
142+
strings.Contains(content, "Silence is golden") ||
143+
strings.Contains(content, "// silence") ||
144+
content == "<?php" ||
145+
content == "<?php\n" {
146+
return nil
147+
}
148+
}
149+
}
150+
135151
return &HeuristicFinding{
136152
FilePath: path,
137153
CheckID: "HEURISTIC_RECENT_PHP",

internal/malware/wp_database.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,26 @@ func queryForMalware(host, user, pass, db, query string, root WebRoot) []string
120120
}
121121

122122
cmd := exec.Command("mysql", args...)
123-
output, err := cmd.CombinedOutput()
123+
// Use Output() not CombinedOutput() — stderr contains MariaDB deprecation
124+
// warnings ("Deprecated program name") that look like injected content.
125+
output, err := cmd.Output()
124126
if err != nil {
125127
return nil
126128
}
127129

128130
var results []string
129131
for _, line := range strings.Split(string(output), "\n") {
130132
line = strings.TrimSpace(line)
131-
if line != "" {
132-
results = append(results, line)
133+
if line == "" {
134+
continue
133135
}
136+
// Skip MariaDB/MySQL warnings that leak into stdout via shell redirects
137+
if strings.Contains(line, "Deprecated program name") ||
138+
strings.HasPrefix(line, "Warning:") ||
139+
strings.HasPrefix(line, "mysql:") {
140+
continue
141+
}
142+
results = append(results, line)
134143
}
135144
return results
136145
}

0 commit comments

Comments
 (0)