Computer >> Hướng Dẫn Máy Tính >  >> Kết Nối Mạng >> An Ninh Mạng

Cách xem xét quyền hạn mạng (Network Security Permissions / Access Review) trên Windows, Azure, Linux

Review quyền truy cập mạng (Network Security Permissions / User Access Review)

Xem xét quyền hạn (Access Review / Access Certification) là quy trình định kỳ kiểm tra: Ai có quyền truy cập cái gì? Có phù hợp không? Có cần thiết không? Mục tiêu: Least Privilege, Giảm bề mặt tấn công, Tuân thủ (Compliance).

1. Kiểm tra quyền file/thư mục trên Windows (NTFS Permissions)

GUI:

  1. Chuột phải File/Folder > Properties > Tab Security
  2. Nhấn Advanced > Tab Permissions / Effective Access
  3. Effective Access: Chọn User/Group > View effective access - Xem quyền thực tế (kết hợp Allow/Deny, Inheritance)

PowerShell (Automation):

# Lấy ACL thư mục
Get-Acl "C:\Data\Finance" | Format-List

# Xem quyền hiệu lực của user cụ thể
(Get-Acl "C:\Data\Finance").Access | Where-Object {$_.IdentityReference -like "*FinanceTeam*"}

# Export ra CSV audit
Get-ChildItem "C:\Data" -Recurse -Directory | ForEach-Object {
    $acl = Get-Acl $_.FullName
    $acl.Access | Select-Object @{N='Path';E={$_.FullName}}, IdentityReference, FileSystemRights, AccessControlType, IsInherited, InheritanceFlags
} | Export-Csv "NTFS_Permissions_Audit.csv" -NoTypeInformation

2. Kiểm tra quyền Share (SMB Share Permissions)

GUI: Properties > Sharing > Advanced Sharing > Permissions
PowerShell:

Get-SmbShare | ForEach-Object {
    $share = $_
    Get-SmbShareAccess -Name $share.Name | Select-Object @{N='ShareName';E={$share.Name}}, AccountName, AccessControlType, AccessRight
} | Format-Table -AutoSize

3. Kiểm tra quyền Network Drive / Mapped Drive

  • File Explorer > This PC > Network locations > Chuột phải Drive > Properties > Security / Sharing
  • Hoặc: `net use` xem mapping, `whoami /groups` xem group membership

4. Review quyền truy cập User/Group (User Access Review / Entitlement Review)

Quy trình chuẩn (Quarterly/Annually):

  1. Inventory: Liệt kê tất cả tài nguyên (AD Groups, Azure AD/Entra ID Roles, App Roles, Server Local Groups, DB Roles, SharePoint, Teams, VPN, Firewall Rules)
  2. Attestation: Gửi cho Manager/Application Owner review: "User X có cần Group Y không?"
  3. Decision: Certify (Giữ), Revoke (Thu hồi), Modify (Điều chỉnh)
  4. Remediation: Thực hiện thay đổi, document lý do
  5. Reporting: Báo cáo cho Audit/Compliance (SOX, ISO 27001, PCI-DSS)

Công cụ tự động hóa: Microsoft Entra ID Access Reviews (P2), SailPoint, Saviynt, Okta Access Certifications, CyberArk, BeyondTrust.

5. Kiểm tra quyền trên Azure (Azure RBAC / NSG / ASG)

Azure RBAC (Role Assignments):

# Liệt kê role assignment cho subscription/resource group
Get-AzRoleAssignment -ResourceGroupName "rg-prod" | Format-Table RoleDefinitionName, DisplayName, Scope

# Kiểm tra quyền hiệu lực của user trên resource
Get-AzRoleAssignment -SignInName "user@domain.com" -Scope "/subscriptions/.../resourceGroups/rg-prod"

# Custom role definition
Get-AzRoleDefinition "Custom VM Operator"

NSG / ASG Rules Review:

# Xem NSG rules
Get-AzNetworkSecurityGroup -Name "nsg-prod-web" -ResourceGroupName "rg-prod" | Select-Object -ExpandProperty SecurityRules | Format-Table Name, Priority, Direction, Access, Protocol, SourcePortRange, DestinationPortRange, SourceAddressPrefix, DestinationAddressPrefix

# Xem ASG membership
Get-AzApplicationSecurityGroup -ResourceGroupName "rg-prod" | ForEach-Object {
    $asg = $_
    Get-AzNetworkInterface -ResourceGroupName "rg-prod" | Where-Object {$_.IpConfigurations.ApplicationSecurityGroups.Id -contains $asg.Id} | Select-Object @{N='ASG';E={$asg.Name}}, Name, PrivateIpAddress
}

6. Kiểm tra quyền trên Linux (File Permissions / ACL / Sudo)

Standard Permissions:

ls -la /path/to/dir
# drwxr-x---  user  group  ...
# User: rwx, Group: r-x, Other: ---

ACL (Access Control Lists) - Chi tiết hơn:

getfacl /path/to/file
# user:john:rwx
# group:finance:r-x
# mask:rwx
# other:---

Sudo Privileges:

sudo -l -U username
# User username may run: (ALL) NOPASSWD: /usr/bin/systemctl restart nginx

Capabilities (Fine-grained):

getcap /usr/bin/ping
# /usr/bin/ping = cap_net_raw+ep

7. Reset quyền (Permission Reset) - Chỉ khi cần thiết

Windows (ICACLS):

# Reset file
icacls "C:\path\file.txt" /reset

# Reset thư mục đệ quy
icacls "C:\path\folder" /reset /t /c /q

# Backup ACL trước khi sửa
icacls "C:\path" /save "acl_backup.txt" /t
icacls "C:\path" /restore "acl_backup.txt"

Linux (chmod/chown/setfacl):

# Reset về mặc định an toàn (ví dụ)
chown -R root:root /etc
chmod -R 644 /etc
chmod 755 /etc /etc/*/  # thư mục executable
# Hoặc dùng rpm/deb restore: rpm --setperms packagename

8. Best Practices cho Access Review

  • Định kỳ: Quý (Critical systems), 6 tháng (Normal), Năm (Low risk)
  • RBAC (Role-Based Access Control): Gán quyền qua Group/Role, KHÔNG gán trực tiếp User
  • Least Privilege: Chỉ cấp quyền tối thiểu để làm việc
  • Separation of Duties (SoD): Người tạo ≠ Người duyệt ≠ Người thực thi
  • Just-in-Time (JIT) / Privileged Access Management (PAM): Cấp quyền admin tạm thời, audit trail
  • Automate: Entra ID Access Reviews, Scripts PowerShell/CLI, SIEM correlation
  • Document: Policy, Procedure, Evidence (Screenshot, CSV, Ticket)