RENATTACH(1)
π RENATTACH π β from the General Commands Manual section, bestie
okay so picture this: you're a mail server, people keep sending each other worms dressed up as invoice.pdf.exe, and you need a bodyguard. that's renattach. it's a renattach (1) page, it lives in the General Commands Manual, and it is lowkey one of the most useful little UNIX tools ever. let's get into it π¦
β¨ NAME β¨
renattach β rename/delete dangerous email attachments π
β¨ SYNOPSIS β¨
renattach [OPTIONS]
that's it. that's the whole vibe. options only, no positional args, she's clean like that β¨
β¨ DESCRIPTION β¨
okay so renattach is a fast and efficient UNIX stream filter that can rename or delete potentially dangerous e-mail attachments. it is a highly effective way of protecting your end-users from harmful mail content (worms/viruses) by disabling or removing attachments that might get accidentally executed by users. no cap. π‘οΈ
the filter gets invoked as a simple pipe, so it slots into a wide variety of systems. and the kill feature β which eliminates entire messages, like, gone, poof β can also help sites deal with resource strains caused by modern virus floods. π
renattach is written in pure C and can quickly process mail with little overhead. she's fast. π¨
and here's the thing β unlike a conventional virus scanner, there are no specific virus or worm definitions. instead, renattach identifies potentially dangerous attachments based on file extension and executable encoded body content. and the software is even capable of reading filenames from inside ZIP archives on the fly, without requiring any external software. not me being self-contained and iconic π
the self-contained MIME code parses, fully interprets, then rewrites the header of every attached file. during this process it checks the file's extension against a list, and further checks to make sure the filename is not on a banned list. only after passing through these steps is the MIME header written fresh using a predetermined, known format. like, she doesn't trust the original header at all, she writes a new one. queen behavior π
the program's operation is simple: a single mail message is read from stdin, filtered, then written to stdout (or piped to an external command).
renattach looks for its configuration file (renattach.conf) in the path specified at compile time. alternatively, you can specify the location of renattach.conf by using the -c command-line options. for example:
renattach -c renattach.conf
β¨ OPTIONS β¨
π¨ okay bestie, listen. the filter's default behaviour is to rename dangerous attachments that match the badlist β{mode=badlist, action=rename}. BUT. if you're searching inside ZIP archives for filenames (see thesearch_zipconfiguration option), the only actions that modify the ZIP files aredeleteandkillbut NOTrename. so the default rename action has no effect on ZIP files. instead, use the--deleteor--killoptions. or, alternatively, append the/dand/kswitches to badlist extensions in the.conffile to selectively delete or kill some file types while just renaming the rest. periodt. π
-a,--allβ Filter mode: match all attachments. every single one. no skipping π«Ά-b,--badlistβ Filter mode: only match filenames that have extensions listed on the bad-list. this will match only attachments with known dangerous file extensions. this is the default β¨-c,--configfilename β use the specified configuration file. runrenattachwith--settingsto verify the current settings. (yes, verify. always verify. trust but check, bestie π)-d,--deleteβ Filter action: delete attachment body after renaming headers. bye bye π-e,--excodeβ extend exitcodes with a new code,77=filtering occurred. see below for standard exit codes β¬οΈ-g,--goodlistβ Filter mode: match all attachments except those that have extensions listed on the goodlist. inverse girlie π-h,--helpβ show help, explain options. the classic π-k,--killβ Filter action: kill (absorb) the entire email. there is null output. nothing survives. π-l,--loopβ removeDelivered-Toheaders to prevent malicious mail forwarding loop. this can prevent Postfix from inadvertently relaying spam.
β οΈ careful!! this option must only be used when renattach is a filter service to the outside world, otherwise you will lose loop protection. do not use from procmail. fr fr, this one has consequences π
-p,--pipecommand [args] β instead of writing output tostdout, open pipe to command (with args) and send output there. this program must return with exit code0. this must be the last option on the command line. see theINSTALLfile for instructions on integrating with Postfix as a filter service π-r,--renameβ Filter action: rename matching attachments (default). the MIME type is also renamed tonew_mime_typefrom the.conffile β¨-s,--settingsβ show current settings/configuration and terminate. peek behind the curtain π-v,--verboseβ write verbose output (including settings) tostderrπ’-V,--versionβ display software version and terminate. the flex π
β¨ EXIT CODES β¨
0β Success (filtered mail and wrote output) β75β Temporary failure (resource shortage; failed to write to pipe if using--pipe) π΅255β Critical failure (improper parameters; bad.conffile) π
the temporary failure code allows MTAs to re-queue mail for later delivery. these exit codes are compatible with BSD-style mailers, and --excode should not be used without good reason because it returns a non-success code when the filter "catches" something. like, it works, but it's telling the MTA something different than the default behavior does. iykyk π§
π CONFIGURATION FILE π
okay so bestie, the .conf file? it's giving plaintext, and the vibe is one configuration directive per line. that's the whole thing. any line that's a comment β anything with a # in front of it β gets ignored, so go ahead and scribble notes to yourself, it's fine π
some directives can only appear once (one and done, main character only), but the others are lists, and lists are additive β they stack, they accumulate, they keep showing up π
and here's the iconic part: the conf file itself is optional, and so is literally every directive in it, because defaults are compiled straight into the software. so likeβ¦ you can rawdog it with zero config and renattach will still do its thing π¦
NOTE: please run renattach --settings to verify your configuration! no cap, do this. fr fr. π
π Description of all options π
here's the whole menu, bestie. every single one. i'm not skipping a thing π
# renattach 1.2.4 recognizes the following configuration directives.
delete_exeβ deletes executable binary attachments by signature. renattach goes looking for encoded bytes that identify DOS/Windows executables ('MZ'). if an executable is found, the encoded attachment gets removed while the MIME header stays unchanged. this is a feature that works independently of filename-based filtering β it's designed as a backup. net effect: encoded executables are deleted. specifyyesorno, or alternatively1or0.
# delete_exe = yes
kill_exeβ kills executable binary attachments by signature, exactly like the previous directive. β οΈ note thatdelete_exeandkill_exeare mutually exclusive β pick one, bestie, you cannot have both.
# kill_exe = no
search_zipβ searches for filenames within ZIP archives using the internal ZIP parsing engine (no external software required, we're self-sufficient π ). any filenames found are subject to the same checks, for instancebadlistorgoodlist, with the notable difference that the RENAME ACTION HAS NO EFFECT on ZIP files. only the delete or kill actions will modify ZIP files.
# search_zip = no
pass_contentidβ normally, MIME Content-ID fields are dropped during filtering due to their application-specific use and security risk (recently used by worms to link malicious code to embedded images π). if you are sure you want to pass Content-ID fields unfiltered, enable this option.
# pass_contentid = no
full_renameβ normally, all periods in filenames are replaced with underscores during renaming. although this is the recommended mode, you can also disable full renaming if you only want the last period to be changed to an underscore.
# full_rename = yes
use_syslogβ if enabled, all filtering actions will be logged via syslog. renattach logs with priority'warning'to facility'mail'.
# use_syslog = no
generic_nameβ a generic filename to use when parsing fails. since renattach rewrites all attachment headers, it's possible that corruption, lack of buffer space, or some other problem will prevent filenames from being recreated. in such a case, this generic name is used. (a little fallback bestie, a safety net π«Ά)
# generic_name = filename
new_extensionβ a replacement file extension to use when changing dangerous attachment filenames. this extension is appended to the previous one. for instancevirus.pifbecomesvirus_pif.bad. specify just#to leave the extension as is, and not rename it.
# new_extension = bad
new_mime_typeβ when attachments are renamed, the MIME type is also changed to thisnew_mime_typefor safety.
# new_mime_type = application/unknown
the following directives control how the message Subject is modified to inform the user that filtering has occurred. they have the following ORDER OF PRIORITY (starting with highest): subj_banned, subj_exec, subj_deleted, subj_renamed, add_subject.
by default, only add_subject is defined, so any condition (whether it's a ban, executable match, delete, or rename) results in the same Subject addition. if you also define subj_exec then there could be a different Subject if an executable was caught (since it has higher priority than add_subject). another alternative for these options is to specify the single character # to suppress Subject modification for that condition. you could use this to be quiet in case a banned attachment is caught. you can also use # to turn off add_subject, hence NEVER modify the message Subject. silence, iconic, mysterious π
subj_bannedβ add text to Subject if an attachment is caught bybanned_files, shown here in suppression mode to NOT inform user on file ban.
# subj_banned = #
subj_execβ add text to Subject if an attachment is caught bydelete_exe.
# subj_exec = [removed executable]
subj_deletedβ add text to Subject if an attachment is deleted for any reason.
# subj_deleted = [deleted attachment]
subj_renamedβ add text to Subject if an attachment is renamed for any reason.
# subj_renamed = [renamed attachment]
add_subjectβ add text to Subject if an attachment is filtered in any way. this has the lowest priority, and is only used if the previous ones are undefined. use the single character#to suppress addition to Subject.
# add_subject = [filtered]
htmlwarn_posβ when inserting a warning into HTML parts of messages (warning_html), this tag defines the preferred position to insert the new HTML. if the first tag in the list is found, the warning position is placed just after this tag. as subsequent tags are found, the position advances after each.
# htmlwarn_pos = html, body
warning_textβ if an attachment is filtered, this lets you specify some warning text that will be inserted into any plain text portion(s) of the email. this is effective for informing users of filtered files, but the act of inserting arbitrary text into an email can cause new problems. use with caution. β οΈ
# warning_text = *******************
# warning_text = MAIL SYSTEM WARNING
# warning_text = Attachments removed
# warning_text = *******************
warning_htmlβ inserts a warning message into HTML portions of the email when filtering occurs. the HTML is inserted at a position determined byhtmlwarn_pos(see above) which provides a good hope for adding a visible warning. unfortunately, inserting arbitrary HTML is tricky due to the complexity of markup interactions. inserting warnings in HTML may thoroughly disrupt the original message, so use with caution. π¬
# warning_html = <h1>Mail system warning<h1>
# warning_html = <h2>Attachments removed</h2>
add_headerβ when enabled, these new headers will be added to the message to inform the user about filtering that occurred.
# add_header = X-Filtered-0: *** PLEASE NOTE ***
# add_header = X-Filtered-1: Potentially dangerous attachments have been
# add_header = X-Filtered-2: found in this e-mail, and have either been
# add_header = X-Filtered-3: renamed or deleted for your safety.
banned_filesβ catches specifically named, banned attachment filenames and optionally takes an action (r=rename,d=delete,k=kill). this is an additive option so there is no limit to how many names can be specified. if the name begins with a forward slash ('/'), this substring has to be found;'/foo'matches'foobar'and'eatfoo'. otherwise, the whole name has to match. specify case-insensitive filenames separated by commas. to specify an action on a matching filename, append/r(rename),/d(delete), or/k(kill) to the filename as illustrated in the example.
# banned_files = your_details.zip/r, your_details.pif/k
# banned_files = movie.pif/d, movie.zip, /winmail/d
goodlistβ a list of good (known-safe) attachment file extensions to use in goodlist filtering mode. this is an additive option, so there is no limit to how many filenames can be specified. specify case-insensitive extensions separated by commas.
# goodlist = DOC, PDF, RTF, SXC, SXW, TXT, ZIP
badlistβ a list of bad (known-dangerous) attachment file extensions to use in badlist filtering mode. this is an additive option, so there is no limit to how many filenames can be specified. specify case-insensitive extensions separated by commas. to specify an action for an extension, append/r(rename),/d(delete), or/k(kill) to the filename. this overrides the default action for the filter and can be used to provide special handling for some extensions. an additional switch can be used to specify an action only for files found within ZIP archives. for instance,EXE/k/dtells the filter to kill emails containing EXE attachments, but if the EXE was found inside a ZIP then the attachment is deleted, not killed. (so specific. so precise. we love a nuanced queen π)
# badlist = ADE, ADP, BAS, BAT, CHM, CMD, COM, CPL, CRT, EML, EXE
# badlist = HLP, HTA, HTM, HTML, INF, INS, ISP, JS, JSE, LNK, MDB
# badlist = MDE, MSC, MSH, MSI, MSP, MST, NWS, OCX, PCD, PIF, REG
# badlist = SCR, SCT, SHB, SHS, URL, VB, VBE, VBS, WSC, WSF, WSH
πΈ FILES πΈ
renattach.confβ yeah that's the one, bestie π
π¦ SEE ALSO π¦
π WARRANTY π
okay so legally speaking, bestie, we gotta be real with you:
as per the GNU GPL, there is no warranty for this software. the author makes no guarantees as to software performance or effectiveness. π
renattach is NOT a virus scanner. read that again. it is not a virus scanner, no cap.
filtering is based on MIME headers and detectable filenames; as such, the software tries to handle both correct structures and incorrectly formatted messages. this filter will not catch all dangerous emails, particularly attachments embedded inside attachments. so likeβ¦ stay alert, diva. it's a filter, not a bodyguard π
π AUTHOR π
Copyright (C) 2003-2006 Jem E. Berkes <jberkes@pc-tools.net>
http://www.pc-tools.net/unix/renattach/
and that's a wrap on renattach, bestie β page RENATTACH(1), dated October 2006, the era of the original π
. you read the whole thing, you understood the whole thing, and honestly? that's giving scholar energy. slay, go filter something responsibly π«Άβ¨π
π¦ where this page comes from
- debian bookworm: renattach 1.2.4-5+b1 Β· GPL-2.0-or-later
- debian trixie: renattach 1.2.4-6 Β· GPL-2.0-or-later
- ubuntu jammy: renattach 1.2.4-5 Β· GPL-2.0-or-later
- ubuntu noble: renattach 1.2.4-5build1 Β· GPL-2.0-or-later
- ubuntu questing: renattach 1.2.4-6
- ubuntu resolute: renattach 1.2.4-8 Β· GPL-2.0-or-later
- ubuntu stonking: renattach 1.2.4-8 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms