b) It should have the login failure handling function, and should configure and enable measures such as ending the session, limiting the number of illegal logins, and automatically exiting when the lo

0 27
Due to the limited space, this article mainly introduces the points that need to...
b) It should have the login failure handling function, and should configure and enable measures such as ending the session, limiting the number of illegal logins, and automatically exiting when the lo



Due to the limited space, this article mainly introduces the points that need to be checked for the capability validation, and the detailed technical knowledge may not be written in great detail. Those who need it can pay attention to the official account for irregular updates on the technical details of the 2.0 security assessment clauses, such as the detailed explanation of pam modules, Linux file extended permissions ACLs, etc., which will be updated successively. You can also get the 2022 capability validation guidebook and Linux simulation environment image files for free. It is more effective to simulate and reproduce the analysis with the article.


Without further ado, let's get straight to the point.

When conducting evaluations, we first need to determine the criticality of the assets (note: the security strategies for assets of different criticality levels may vary).

1683161194_6453006ab66744b46b9e6.png!small?1683161197150

Then check the corresponding assets according to the security policy

1683161338_645300fab46883cfc0683.png!small?1683161341416

First, let's take the Linux operating system as an example.

First, identity authentication

a) Identify and authenticate the login user, with unique identity, and the authentication information has complexity requirements and needs to be changed regularly.

Let's take a look at the answer first, and then reproduce the relevant knowledge points based on the answer.

1683160795_6452fedb67e85dc4e058d.png!small?1683160798515

1. Set password length check and complexity check through pam_pwquality, without adding the parameter enforce_for_root, so the root user can set passwords for themselves and other operating system users that do not comply with the password security policy.

On-site situation:

Check /etc/pam.d/system-auth

1683161592_645301f8387f02ba06d03.png!small?1683161595186

Check /etc/security/pwquality.conf

1683161651_64530233e656786268e19.png!small?1683161654917

Determine the corresponding security policy

1683162390_645305166c0f659278725.png!small?1683162392769

According to the screenshot, we can judge that the system sets the corresponding password length and complexity through the pam_pwquality module, and find that the 'minlen' parameter in the 'system-auth' file conflicts with the 'pwquality.conf' file. After testing, the conflicting parameters are in accordance with the configuration in the 'system-auth' file, so here minlen=12.

The final configuration is: minlen=12, minclass=3, maxrepeat=0, maxclassrepeat=0, lcredit=0, ucredit=0, dcredit=0, ocredit=0.

Parameter explanation:

minlen=N the minimum length of the password

maxrepeat the maximum number of consecutive identical characters allowed in the new password, if 0 represents disable

maxclassrepeat the maximum number of consecutive characters of the same type allowed in the new password

dcredit=N N >0 the maximum number of digits in the password plus 1;

N<0 the minimum number of digits in the password

lcredit=N number of lowercase letters

ucredit=N number of uppercase letters

ocredit=N number of special letters

minclass=N password composition (uppercase/lowercase letters, numbers, special characters)

authtok_type= enforce_for_root indicates that the root user also needs to comply with this rule

Therefore, it meets the requirements for length and complexity, but lacks means to restrict the root account. However, after testing, the parameter 'authtok_type= enforce_for_root' written in the 'pwquality.conf' file only prompts but does not take effect, and needs to be written in the 'system-auth' file (not sure what the situation is).

1683170367_6453243f3b8680a7fa338.png!small?1683170369496

So the first point is relatively simple to check, similar ones have been examined before.

The password validity check policy set by PASS_MAX_DAYS in https://www.freebuf.com/articles/system/etc/login.defs only applies to users created after this setting, and after checking the password validity period of each user in the /etc/shadow file, the root and mysql account passwords are valid for 99999 days, which does not meet the security policy requirements

The second point is even simpler, just directly check the /etc/shadow file, and find that the root and mysql accounts are both set to 99999

1683171096_645327186a55f3c9aa080.png!small?1683171099251

Let's take a look at the /etc/login.defs file. The PASS_MAX_DAYS parameter is only applicable to users added after this setting is made, and the PASS_MIN_LEN parameter is invalid. After the root account is set, the password must also be changed when it expires.

1683171245_645327ad9793b0a41669e.png!small?1683171248522

The first line of the /etc/pam.d/sshd file added the configuration item auth sufficient pam_listfile/so onerr=succeed item=user sense=allow file=/etc/bduser, among which the securityM02 users listed in /etc/bduser can log in remotely with any password, bypassing the operating system's authentication process

This section examines the assessor's understanding of the pam authentication module. First, let's look at the corresponding configuration file. Generally, we use ssh for login, so local login may not be required, but it is best to take a look at whether there is any misconfiguration in the system-auth file. Here we check the /etc/pam.d/sshd file

1683172162_64532b427ec4e8362eb9d.png!small?1683172165056

At that time, the author did not investigate this in detail. Although some research has been done on some pam modules, it was felt that it would not be tested this specifically, so it was not delved into. As a result, this time it was tested, and this module was exactly one that had not been recorded, so it was sent directly without being found. There was also no screenshot of /etc/bduser this time. Subsequent local testing found that passwordless login was possible.

Let's first briefly introduce the pam_listfile.so module:

The pam_listfile.so module is similar in function to the pam_access.so module, with the goal of implementing access control based on user/group, hostname/IP, and terminal. However, its implementation method is slightly different from pam_access.so because it does not have a dedicated default configuration file. Access control is achieved through control options in the pam configuration file and a custom configuration file. Moreover, in addition to controlling the aforementioned access sources, it can also control ruser, rhost, the user group, and the login shell. Therefore, some users believe that its functionality seems more flexible and powerful than pam_access.so.

The format of the configuration of pam_listfile.so module is divided into five parts: item, onerr, sense, file, and apply. Among them: }}

a) item=[tty|user|rhost|ruser|group|shell]: Defines which listed targets or conditions adopt the rule. It is obvious that multiple different conditions can be specified here.

b) onerr=succeed|fail: Defines the default return value when an error occurs (such as unable to open the configuration file).

c) sense=allow|deny: Defines the control method when a project that meets the conditions is found in the configuration file. If no such project is found, the general verification will pass.

d) file=filename: Used to specify the full path name of the configuration file.

e) apply=user|@group: Defines the user type (user or group) to which the rule applies.

As for the writing method of the file, it is simple. Just enter a user or group name per line. Therefore, when similar access control is needed for other services, you can copy the pattern. For example, now it is necessary to implement user-based access control for ssh clients on the SSH server.

Example one:

The zfy account is not allowed to log in via ssh. The method is as follows, add this line:

auth required pam_listfile.so item=user sense=deny file=/etc/denyusers onerr=succeed

1683172400_64532c30230d1518b2c96.png!small?1683172402553

Then add this user to the /etc/denyusers file. This user will be denied login, and the rest of the accounts can log in normally.

1683172444_64532c5c135af33502e24.png!small?1683172446354

Example two:

For example, ability verification, there are plenty of explanations and rules for pam modules on the Internet, so they will not be introduced here. Just paste a simple picture.

1683172585_64532ce9deeddcb518d6c.png!small?1683172588777

After passing, the subsequent authentication is not performed, so the users in /etc/bduser can skip password authentication. This means that once the first one is passed, the auth authentication is not performed again, resulting in any password entered by the users in this file can log in.

1683172644_64532d24dcf0fb2476b87.png!small?1683172647890

I can log in successfully by entering any password at will.

1683172660_64532d34b35aef1f2c555.png!small?1683172663763

So, this point may cause more failures. If you haven't studied the pam authentication mechanism yourself, or do not recognize this module, it is easy to ignore it, and the test is quite detailed.

b) It should have the login failure handling function, and should configure and enable measures such as ending the session, limiting the number of illegal logins, and automatically exiting when the login connection times out.

As usual, let's look at the answer first.

1683356112_6455f9d015c70278f930e.png!small?1683356112515

1683356133_6455f9e51dc23c8f45409.png!small?1683356133703

1. The login failure handling measures only take effect for users logging in remotely via SSH, and are invalid for local login users and other remote login methods (the Telnet remote login on this machine is enabled, tcp/50629).

Confirm how the strategy of the login failure handling function for the corresponding key assets is.

1683356853_6455fcb5af32cbbec9ce5.png!small?1683356854033


For the login failure handling function of ssh, we check the /etc/pam.d/sshd file.

1683356362_6455faca9638179b45ec7.png!small?1683356363285

After confirming that the configuration of the login failure handling function for the ssh login method is correct, the pitfall comes next. Does it only have one ssh login method? First, we use the netstat -tuanp command to view the port openness status.

1683357095_6455fda77908c576365a9.png!small?1683357096001

Pay attention to the port with the unknown Program name mentioned above, among which there must be some pitfalls. The author is a bit clumsy and does not know how to install the telnet service successfully on the CentOS 7 version, as I directly installed the telnet program, which is systemd (the telnet service of the 2021 ability verification is this), CentOS 7 no longer uses the xinetd service to start telnet, so it may not be possible to reproduce the success here.

1683357726_6456001ea3d0aaa07f9be.png!small?1683357727074

According to the information on the Internet, we can find the port corresponding to the telnet service by viewing the /etc/services file.

1683357815_64560077e8c7cebbc6dfa.png!small?1683357816576

For CentOS 7, modify the ListenStream parameter of the /usr/lib/systemd/system/telnet.socket file.

1683359618_6456078254687c92dbaeb.png!small?1683359618534

1683359571_645607532fdc592dbf4ea.png!small?1683359571441

So, if the login failure handling function does not have the telnet module, it cannot meet the requirements.

Although export TMOUT 900 is set in /etc/profile, this configuration is not placed at the end of the file. After this configuration, /etc/profile configures to load all script files under the /etc/profiled/ directory, among which /etc/profiled/idletimeout.sh is configured with export TMOUT 3600, overriding the TMOUT setting in /etc/profile. By echoing $TMOUT, we can know that the actual effective idle timeout time is 3600 seconds, which does not meet the requirements of the security policy.

Check the security policy

1683360301_64560a2d154e2b46adffd.png!small?1683360301406

Here is usually to view the /etc/profile file, and it was also viewed at the time of the test.

1683360035_645609234a9f5f0325e37.png!small?1683360035523

But the most stable way is to output the current TMOUT value of the environment variable, using the echo $TMOUT command

1683360150_6456099613837fe5509f7.png!small?1683360150317

It was very纠结 at that time, I didn't know where he had configured another 3600. At first, I thought it was configured in the .bash_profile file under the user's home directory, but later found out that it was not. So the configuration file may be many kinds, and in the case of uncertainty, directly echo $TMOUT, I think this should also be given points. Since I didn't check the /etc/profiled/idletimeout.sh file at that time, I couldn't reproduce how he configured it.

When performing remote management, necessary measures should be taken to prevent the eavesdropping of authentication information during transmission over the network

1683360258_64560a027047f82794ca4.png!small?1683360259001

This one is very clear, you can directly check the server's port opening status on the day with netstat -tuanp

1683357095_6455fda77908c576365a9.png!small?1683357096001

Then go to the /etc/services file to confirm which service it is. This has been explained above, so there is no need to repeat it here.


你可能想看:

b) It should have a login failure handling function, and should configure and enable measures such as ending the session, limiting the number of illegal login attempts, and automatically logging out w

In today's rapidly developing digital economy, data has become an important engine driving social progress and enterprise development. From being initially regarded as part of intangible assets to now

4.5 Main person in charge reviews the simulation results, sorts out the separated simulation issues, and allows the red and blue teams to improve as soon as possible. The main issues are as follows

d) Adopt identification technologies such as passwords, password technologies, biometric technologies, and combinations of two or more to identify users, and at least one identification technology sho

Ensure that the ID can be accessed even if it is guessed or cannot be tampered with; the scenario is common in resource convenience and unauthorized vulnerability scenarios. I have found many vulnerab

5. Collect exercise results The main person in charge reviews the exercise results, sorts out the separated exercise issues, and allows the red and blue sides to improve as soon as possible. The main

Announcement regarding the addition of 7 units as technical support units for the Ministry of Industry and Information Technology's mobile Internet APP product security vulnerability database

5: Determine if the email account exists (if an existing email is found, you can directly exploit the vulnerability)

It is possible to perform credible verification on the system boot program, system program, important configuration parameters, and application programs of computing devices based on a credible root,

Article 2 of the Cryptography Law clearly defines the term 'cryptography', which does not include commonly known terms such as 'bank card password', 'login password', as well as facial recognition, fi

最后修改时间:
admin
上一篇 2025年03月27日 10:34
下一篇 2025年03月27日 10:57

评论已关闭