Bug 84276 - portmap hosts.deny search doesn't terminate on first match
Summary: portmap hosts.deny search doesn't terminate on first match
Keywords:
Status: CLOSED CANTFIX
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: portmap
Version: 9
Hardware: i386
OS: Linux
high
medium
Target Milestone: ---
Assignee: Steve Dickson
QA Contact: Jay Turner
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-02-13 21:46 UTC by Ned Bass
Modified: 2015-01-08 00:03 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2007-01-02 18:56:47 UTC
Embargoed:


Attachments (Terms of Use)
fixed logic in consoluting access control lists (2.00 KB, patch)
2003-04-24 20:44 UTC, Ned Bass
no flags Details | Diff

Description Ned Bass 2003-02-13 21:46:27 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020607

Description of problem:
The portmap daemon does not terminate its search of the hosts.deny table on the
first match.  For example, given the following lines
in hosts.deny:

# silently deny access to nessus scanner
portmap : 192.168.1.100
# Deny access to everyone and send an email alert.
portmap : ALL : \
spawn ( echo "Failed %d attempt from %h (%a) on server %H (%A)" \
    | /bin/mail -s "******** TCPWRAPPER ALERT ********" root) &

an email alert is still generated after receiving a connection to the portmapper
from 192.168.1.100.  I can verify that both rules are being processed by
changing the first line to also send an email alert, in which case I would
receive two email alerts per connection.

I have found that if I rebuild the portmap source rpm without including the
patch portmap-4.0-cleanup.patch, then this problem does not occur when using the
rebuilt package.

Version-Release number of selected component (if applicable):
4.0-35

How reproducible:
Always

Steps to Reproduce:
1. add two portmap lines in /etc/hosts.deny that match a given host, doing
nothing in the first line but sending an email alert in the second line.
2. initiate a connection to the portmap daemon from the host being denied by the
first line
3. check email
    

Actual Results:  I recevied an email alert resulting from the portmap connection.

Expected Results:  An email alert should not have been generated.

Additional info:

I have also tried using portmap-4.0-45 from rawhide, and the problem still
exists there.  I am using tcp_wrappers-7.6-18.

Comment 1 Ned Bass 2003-04-24 20:44:16 UTC
Created attachment 91283 [details]
fixed logic in consoluting access control lists

The correct behavior is achieved by reversing the logic in the good_client()
function in pmap_check.c.  When consoluting the access control lists using the
hosts_ctl() function from libwrap.a, rather than good_client() returning 1 when
getting a non-zero result from hosts_ctl, then returning zero if it gets to the
end, it should return zero when it gets a zero result from hosts_ctl, then
return 1 if it gets to the end.  That way a client connection is refused if any
of its IP, hostname, or alias is being denied in the host access control files.
 As the function currently exists, all three host representations must be
explicitly denied for the connection to be rejected.

Comment 2 Ned Bass 2003-04-25 04:06:35 UTC
On second thought, this approach does not achieve the correct behavior, it just
reverses it.  With this patch, all three host representations (IP, hostname,
aliases) must be explicitly allowed for a connection to be accepted.  In any
case, it would be preferable to just not apply the portmap-4.0-cleanup patch,
and return to filtering connections only by IP address, as is described in the
portmap documentation.

Comment 3 Ned Bass 2003-04-29 21:35:16 UTC
Raising priority to high since this bug results in host access control table
rules being ignored, and is still present in RH9.

Comment 5 Guy Streeter 2005-08-09 19:41:08 UTC
OK, here's what happens.
portmap uses the host_ctl() function provided by the tcp_wrappers package to
check the allow and deny lists, and it does the check in parts, like this:
1. It checks the IP address of the client. If access is allowed, it stop there.
2. It check the canonical hostname associated with the IP address of the client.
If access is allowed, it stop there.
3. It checks each alias name associated with the IP address of the client. It
stops if one of them is allowed access.
4. If it runs out of aliases, access is not allowed.

As you can see, even with an IP address rule in place, subsequent checks against
the name and aliases may reach the ANY rule.

In order to keep the ANY rule from being hit in /etc/hosts.deny, you'll need to
put the IP address and the DNS name and all DNS aliases of the client IP address
in rules before the ANY rule. You can put them all in one rule as a
comma-separated list.

Comment 6 Bill Nottingham 2006-08-05 04:24:55 UTC
Red Hat apologizes that these issues have not been resolved yet. We do want to
make sure that no important bugs slip through the cracks.

Red Hat Linux 7.3 and Red Hat Linux 9 are no longer supported by Red Hat, Inc.
They are maintained by the Fedora Legacy project (http://www.fedoralegacy.org/)
for security updates only. If this is a security issue, please reassign to the
'Fedora Legacy' product in bugzilla. Please note that Legacy security update
support for these products will stop on December 31st, 2006.

If this is not a security issue, please check if this issue is still present
in a current Fedora Core release. If so, please change the product and version
to match, and check the box indicating that the requested information has been
provided.

If you are currently still running Red Hat Linux 7.3 or 9, please note that
Fedora Legacy security update support for these products will stop on December
31st, 2006. You are strongly advised to upgrade to a current Fedora Core release
or Red Hat Enterprise Linux or comparable. Some information on which option may
be right for you is available at http://www.redhat.com/rhel/migrate/redhatlinux/.

Any bug still open against Red Hat Linux 7.3 or 9 at the end of 2006 will be
closed 'CANTFIX'. Again, if this bug still exists in a current release, or is a
security issue, please change the product as necessary. We thank you for your
help, and apologize again that we haven't handled these issues to this point.


Comment 8 Bill Nottingham 2007-01-02 18:56:47 UTC
Red Hat Linux 7.3 and Red Hat Linux 9 are no longer supported by Red Hat, Inc.
f you are currently still running Red Hat Linux 7.3 or 9, you are strongly
advised to upgrade to a current Fedora Core release or Red Hat Enterprise Linux
or comparable. Some information on which option may be right for you is
available at http://www.redhat.com/rhel/migrate/redhatlinux/.

Closing as CANTFIX.


Note You need to log in before you can comment on or make changes to this bug.