Page MenuHomeFreeBSD

dhclient: Improve server and filename validation
ClosedPublic

Authored by des on Thu, Apr 30, 8:24 AM.
Tags
None
Referenced Files
F155105589: D56740.id176887.diff
Fri, May 1, 10:55 AM
F155105586: D56740.id176901.diff
Fri, May 1, 10:55 AM
F155105567: D56740.diff
Fri, May 1, 10:55 AM
Unknown Object (File)
Thu, Apr 30, 6:34 PM
Unknown Object (File)
Thu, Apr 30, 2:28 PM
Unknown Object (File)
Thu, Apr 30, 2:23 PM
Unknown Object (File)
Thu, Apr 30, 2:17 PM
Unknown Object (File)
Thu, Apr 30, 2:11 PM
Subscribers

Details

Summary
  • Don't iterate over each string three times; once is enough.
  • Reject control characters (anything below space) in addition to the double quote and backslash.
  • If an unsafe character is encountered, discard the string instead of rejecting the entire lease.
  • If backslashes are encountered in the file name option, convert them to forward slashes instead of rejecting the option.
  • Tweak the warning messages a bit. Looking through the rest of the code, it seems to me that notes generally end with a period while warnings generally don't.

Fixes: 8008e4b88daf ("dhclient: Check for unexpected characters in some
DHCP server options")
PR: 294886
MFC after: 1 week

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

des requested review of this revision.Thu, Apr 30, 8:24 AM

no need for else after break

brooks added a subscriber: brooks.

The net effect look like the right one. I'm not convinced by the open-coding the checks and copy given the lease processing rate should single digits per hour in most environments and it will all be in L1 on even a terrible in-order core, but I don't care that much.

sbin/dhclient/dhclient.c
1267
This revision is now accepted and ready to land.Thu, Apr 30, 10:34 AM
This revision now requires review to proceed.Thu, Apr 30, 10:38 AM
des marked an inline comment as done.Thu, Apr 30, 10:38 AM
andrew added inline comments.
sbin/dhclient/dhclient.c
1222–1223

Is this correct?

sbin/dhclient/dhclient.c
1222–1223

This is backwards, indeed.

des marked 2 inline comments as done.Thu, Apr 30, 1:38 PM
des added inline comments.
sbin/dhclient/dhclient.c
1222–1223

Thanks, I just hacked this up quickly when I saw the PR, and unfortunately I don't have a way of testing it.

des marked an inline comment as done.Thu, Apr 30, 1:38 PM
This revision is now accepted and ready to land.Thu, Apr 30, 1:43 PM
sbin/dhclient/dhclient.c
1269

Probably we should avoid printing this message if the offending char is a backslash, as that's a normal situation.

des marked an inline comment as done.

convert backslashes in file names to forward slashes

This revision now requires review to proceed.Thu, Apr 30, 2:05 PM
This revision is now accepted and ready to land.Thu, Apr 30, 2:10 PM
This revision was automatically updated to reflect the committed changes.