🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.admin.peering
Article #3753

Re: filter_nnrpd.pl - critical

#3753
From: Billy G.
Date: Mon, 04 Aug 2025 22:55
88 lines
3545 bytes
On 04.08.25 18:03, Billy G. wrote:
> this file was extracted from i2pn2.org
> 
> but some files are missing :/
> 
> # filter_nnrpd.pl
> #
> # Do any initialization steps.
> #
> use Digest::SHA qw(hmac_sha256_base64 hmac_sha512_base64 sha256_hex ....

Claude4 says (that's AI):

Looking at this code,
I can see several **serious security vulnerabilities**!

Let me highlight the major issues:
Yes, there are **multiple serious security vulnerabilities**!

Here are the critical issues:

## 🚨 **CRITICAL SECURITY VULNERABILITIES**

### **1. Path Traversal via Message Headers (CRITICAL)**
```perl
$postedfile = "/news/spam/posted/".$hdr{"From"}."-".$hdr{"Message-ID"};
```
- `$hdr{"From"}` and `$hdr{"Message-ID"}` come directly from user input
- An attacker could set: `From: ../../../etc/passwd`
- This creates: `/news/spam/posted/../../../etc/passwd-<msgid>`
- **Impact**: Write to arbitrary files on the system!


### **2. Command Injection via Shell Execution (CRITICAL)**
```perl
$rval = `/usr/bin/php /news/spam/bin/checkrate.php $arguments`;
$spamvalue = `/usr/bin/php /news/spam/bin/i2pn2-spamassassin.php 
$sa_arguments`;
```
- Variables contain user-controlled data despite escaping
- The escaping only handles `$` and `"` but misses other shell 
metacharacters
- **Impact**: Remote command execution!


### **3. Weak Temporary File Generation**
```perl
$tempfile = rand(100);
```
- Predictable filenames (0-99)
- **Impact**: Race conditions, file collision attacks


### **4. Unescaped Data in Log Files**
```perl
print $fh "\n    " . $note . "by: " . $user . " as " . $hdr{"From"};
```
- User data written directly to logs
- **Impact**: Log injection, potential log poisoning


### **5. Insufficient Input Validation**
The escaping is incomplete:
```perl
$mid =~ s/([\$"])/\\$1/g;     # Only escapes $ and "
```
Missing: `;`, `|`, `&`, `` ` ``, `(`, `)`, `\n`, etc.


## 🛠️ **How to Fix These Issues**

Would you like me to create a secured version that:
1. Validates and sanitizes all file paths
2. Uses proper shell escaping or avoids shell calls entirely
3. Implements secure temporary file generation
4. Adds comprehensive input validation
5. Uses prepared statements/safer execution methods

This code is **extremely dangerous** in its current state and should not 
be deployed without these security fixes!

-- 
.......
Billy G. (go-while)
https://pugleaf.net
@Newsgroup: rocksolid.nodes.help
irc.pugleaf.net:6697 (SSL) #lounge
discord: https://discord.gg/rECSbHHFzp
Technical Details
Message-ID: <106rdpj$qu2g$4@reader-nyc.newsdeef.eu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.pugleaf.net!ygg-lux.newsdeef.eu!lux-feed1.newsdeef.eu!reader-nyc.newsdeef.eu!.POSTED!not-for-mail
References: <106qp4f$qu2g$3@reader-nyc.newsdeef.eu>

Show Full Headers
Complete Article Headers
Message-ID: <106rdpj$qu2g$4@reader-nyc.newsdeef.eu>
Subject: Re: filter_nnrpd.pl - critical
Date: Mon, 4 Aug 2025 23:55:42 +0100
From: "Billy G." <no-reply@no.spam>
References: <106qp4f$qu2g$3@reader-nyc.newsdeef.eu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.pugleaf.net!ygg-lux.newsdeef.eu!lux-feed1.newsdeef.eu!reader-nyc.newsdeef.eu!.POSTED!not-for-mail
Newsgroups: news.admin.peering
Organization: github.com/go-while
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 4 Aug 2025 22:55:48 -0000 (UTC)
Injection-Info: reader-nyc.newsdeef.eu; posting-account="sys-operator";
 logging-data="882768"; mail-complaints-to="abuse@newsdeef.eu"
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <106qp4f$qu2g$3@reader-nyc.newsdeef.eu>