Skip to content

pam_access: handle the 'LOCAL' keyword more securely#343

Closed
jo-he wants to merge 1 commit intolinux-pam:masterfrom
jo-he:master
Closed

pam_access: handle the 'LOCAL' keyword more securely#343
jo-he wants to merge 1 commit intolinux-pam:masterfrom
jo-he:master

Conversation

@jo-he
Copy link
Copy Markdown

@jo-he jo-he commented Apr 1, 2021

Previously, for remote connections (e.g. SSH) it slipped through to 'network_netmask_match', where it was rejected just luckily, because it does does not mach a netmask pattern or an IP address.

This can become a security issue, when Linux vendors extend 'network_netmask_match', e.g. with hostname resolution (like SUSE did in SLES 15). So better prefer the code to be locally correct.

Previously, for remote connections (e.g. SSH) it slipped through
to 'network_netmask_match', where it luckily was just rejected,
because it does does not mach a netmask pattern or IP address.
@jo-he
Copy link
Copy Markdown
Author

jo-he commented Apr 1, 2021

Pull request #226 is the SUSE patch I was referring to. Without fixing the LOCAL check, it would fill the syslog with cannot resolve hostname "LOCAL" messages.

Comment on lines 623 to +627
} else if (item->from_remote_host == 0) { /* local: no PAM_RHOSTS */
if (strcasecmp(tok, "LOCAL") == 0)
return (YES);
} else if (strcasecmp(tok, "LOCAL") == 0) {
return NO;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be rewritten in a more logical way:

} else if (strcasecmp(tok, "LOCAL") == 0) {
   if (item->from_remote_host == 0)
       return YES;
   return NO;
} else if ....

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is not the same logic. With your suggestion, local accesses would fall through, when LOCAL is not configured.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. But I still prefer doing it differently so that the comparison of tok with LOCAL is not done twice. My alternate PR: #345

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, that clean-up makes it more readable. I just added some minor comments.

@t8m
Copy link
Copy Markdown
Member

t8m commented Apr 12, 2021

Closing as alternative PR was merged. But thank you for the heads up!

@t8m t8m closed this Apr 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants