Skip to content

Commit dfe678a

Browse files
Update latest docs
1 parent f865dbe commit dfe678a

File tree

173 files changed

+16935
-154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

173 files changed

+16935
-154
lines changed
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
[[prebuilt-rule-8-17-11-attempt-to-establish-vscode-remote-tunnel]]
2+
=== Attempt to Establish VScode Remote Tunnel
3+
4+
Detects the execution of the VScode portable binary with the tunnel command line option indicating an attempt to establish a remote tunnel session to Github or a remote VScode instance.
5+
6+
*Rule type*: eql
7+
8+
*Rule indices*:
9+
10+
* endgame-*
11+
* logs-crowdstrike.fdr*
12+
* logs-endpoint.events.process-*
13+
* logs-m365_defender.event-*
14+
* logs-sentinel_one_cloud_funnel.*
15+
* logs-system.security*
16+
* logs-windows.sysmon_operational-*
17+
* winlogbeat-*
18+
19+
*Severity*: medium
20+
21+
*Risk score*: 47
22+
23+
*Runs every*: 5m
24+
25+
*Searches indices from*: now-9m ({ref}/common-options.html#date-math[Date Math format], see also <<rule-schedule, `Additional look-back time`>>)
26+
27+
*Maximum alerts per execution*: 100
28+
29+
*References*:
30+
31+
* https://badoption.eu/blog/2023/01/31/code_c2.html
32+
* https://code.visualstudio.com/docs/remote/tunnels
33+
34+
*Tags*:
35+
36+
* Domain: Endpoint
37+
* OS: Windows
38+
* Use Case: Threat Detection
39+
* Tactic: Command and Control
40+
* Data Source: Elastic Endgame
41+
* Data Source: Elastic Defend
42+
* Data Source: Sysmon
43+
* Data Source: SentinelOne
44+
* Data Source: Microsoft Defender for Endpoint
45+
* Data Source: Windows Security Event Logs
46+
* Data Source: Crowdstrike
47+
* Resources: Investigation Guide
48+
49+
*Version*: 109
50+
51+
*Rule authors*:
52+
53+
* Elastic
54+
55+
*Rule license*: Elastic License v2
56+
57+
58+
==== Investigation guide
59+
60+
61+
62+
*Triage and analysis*
63+
64+
65+
> **Disclaimer**:
66+
> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
67+
68+
69+
*Investigating Attempt to Establish VScode Remote Tunnel*
70+
71+
72+
Visual Studio Code (VScode) offers a remote tunnel feature enabling developers to connect to remote environments seamlessly. While beneficial for legitimate remote development, adversaries can exploit this to establish unauthorized access or control over systems. The detection rule identifies suspicious use of VScode's tunnel command, focusing on specific command-line arguments and process behaviors, to flag potential misuse indicative of command and control activities.
73+
74+
75+
*Possible investigation steps*
76+
77+
78+
- Review the process details to confirm the presence of the "tunnel" argument in the command line, which indicates an attempt to establish a remote tunnel session.
79+
- Check the parent process name to ensure it is not "Code.exe" when the process name is "code-tunnel.exe" with the "status" argument, as this is an exception in the rule.
80+
- Investigate the origin of the process by examining the user account and machine from which the process was initiated to determine if it aligns with expected usage patterns.
81+
- Analyze network logs to identify any unusual or unauthorized connections to GitHub or remote VScode instances that may suggest malicious activity.
82+
- Correlate the event with other security alerts or logs from data sources like Elastic Endgame, Sysmon, or Microsoft Defender for Endpoint to gather additional context on the activity.
83+
- Assess the risk and impact by determining if the system or user account has been involved in previous suspicious activities or if there are any indicators of compromise.
84+
85+
86+
*False positive analysis*
87+
88+
89+
- Legitimate remote development activities using VScode's tunnel feature may trigger the rule. Users can create exceptions for known developer machines or specific user accounts frequently using this feature for authorized purposes.
90+
- Automated scripts or deployment tools that utilize VScode's remote tunnel for legitimate operations might be flagged. Consider excluding these processes by identifying their unique command-line arguments or parent processes.
91+
- Scheduled tasks or system maintenance activities that involve VScode's remote capabilities could be misidentified as threats. Review and whitelist these tasks by their specific execution times or associated service accounts.
92+
- Development environments that frequently update or test VScode extensions might inadvertently match the rule's criteria. Exclude these environments by setting up exceptions based on their network segments or IP addresses.
93+
- Training or demonstration sessions using VScode's remote features for educational purposes can be mistaken for suspicious activity. Implement exclusions for these sessions by tagging them with specific event identifiers or user roles.
94+
95+
96+
*Response and remediation*
97+
98+
99+
- Immediately isolate the affected system from the network to prevent further unauthorized access or data exfiltration.
100+
- Terminate any suspicious VScode processes identified by the detection rule to halt potential command and control activities.
101+
- Conduct a thorough review of system logs and process histories to identify any additional indicators of compromise or lateral movement attempts.
102+
- Reset credentials and access tokens associated with the affected system and any connected services to mitigate unauthorized access.
103+
- Restore the system from a known good backup if any unauthorized changes or malware are detected.
104+
- Implement network segmentation to limit the ability of similar threats to spread across the environment.
105+
- Escalate the incident to the security operations center (SOC) or incident response team for further investigation and to determine if additional systems are affected.
106+
107+
==== Rule query
108+
109+
110+
[source, js]
111+
----------------------------------
112+
process where host.os.type == "windows" and event.type == "start" and
113+
process.args : "tunnel" and (process.args : "--accept-server-license-terms" or process.name : "code*.exe") and
114+
not (process.name == "code-tunnel.exe" and process.args == "status" and process.parent.name == "Code.exe")
115+
116+
----------------------------------
117+
118+
*Framework*: MITRE ATT&CK^TM^
119+
120+
* Tactic:
121+
** Name: Command and Control
122+
** ID: TA0011
123+
** Reference URL: https://attack.mitre.org/tactics/TA0011/
124+
* Technique:
125+
** Name: Remote Access Tools
126+
** ID: T1219
127+
** Reference URL: https://attack.mitre.org/techniques/T1219/
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
[[prebuilt-rule-8-17-11-aws-s3-static-site-javascript-file-uploaded]]
2+
=== AWS S3 Static Site JavaScript File Uploaded
3+
4+
This rule detects when a JavaScript file is uploaded or accessed in an S3 static site directory (`static/js/`) by an IAM user or assumed role. This can indicate suspicious modification of web content hosted on S3, such as injecting malicious scripts into a static website frontend.
5+
6+
*Rule type*: esql
7+
8+
*Rule indices*: None
9+
10+
*Severity*: medium
11+
12+
*Risk score*: 47
13+
14+
*Runs every*: 5m
15+
16+
*Searches indices from*: now-9m ({ref}/common-options.html#date-math[Date Math format], see also <<rule-schedule, `Additional look-back time`>>)
17+
18+
*Maximum alerts per execution*: 100
19+
20+
*References*:
21+
22+
* https://www.sygnia.co/blog/sygnia-investigation-bybit-hack/
23+
* https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteHosting.html
24+
* https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html
25+
26+
*Tags*:
27+
28+
* Domain: Cloud
29+
* Data Source: AWS
30+
* Data Source: Amazon Web Services
31+
* Data Source: AWS S3
32+
* Tactic: Impact
33+
* Use Case: Web Application Compromise
34+
* Use Case: Cloud Threat Detection
35+
* Resources: Investigation Guide
36+
37+
*Version*: 1
38+
39+
*Rule authors*:
40+
41+
* Elastic
42+
43+
*Rule license*: Elastic License v2
44+
45+
46+
==== Investigation guide
47+
48+
49+
50+
*Triage and Analysis*
51+
52+
53+
54+
*Investigating AWS S3 Static Site JavaScript File Uploaded*
55+
56+
57+
An S3 `PutObject` action that targets a path like `static/js/` and uploads a `.js` file is a potential signal for web content modification. If done by an unexpected IAM user or outside of CI/CD workflows, it may indicate a compromise.
58+
59+
60+
*Possible Investigation Steps*
61+
62+
63+
- **Identify the Source User**: Check `aws.cloudtrail.user_identity.arn`, access key ID, and session type (`IAMUser`, `AssumedRole`, etc).
64+
- **Review File Content**: Use the S3 `GetObject` or CloudTrail `requestParameters` to inspect the uploaded file for signs of obfuscation or injection.
65+
- **Correlate to Other Events**: Review events from the same IAM user before and after the upload (e.g., `ListBuckets`, `GetCallerIdentity`, IAM activity).
66+
- **Look for Multiple Uploads**: Attackers may attempt to upload several files or modify multiple directories.
67+
68+
69+
*False Positive Analysis*
70+
71+
72+
- This behavior may be expected during app deployments. Look at:
73+
- The `user_agent.original` to detect legitimate CI tools (like Terraform or GitHub Actions).
74+
- Timing patterns—does this match a regular release window?
75+
- The origin IP and device identity.
76+
77+
78+
*Response and Remediation*
79+
80+
81+
- **Revert Malicious Code**: Replace the uploaded JS file with a clean version and invalidate CloudFront cache if applicable.
82+
- **Revoke Access**: If compromise is confirmed, revoke the IAM credentials and disable the user.
83+
- **Audit IAM Policies**: Ensure that only deployment users can modify static site buckets.
84+
- **Enable Bucket Versioning**: This can allow for quick rollback and historical review.
85+
86+
87+
==== Rule query
88+
89+
90+
[source, js]
91+
----------------------------------
92+
from logs-aws.cloudtrail* metadata _id, _version, _index
93+
| where
94+
95+
// filter on CloudTrail logs for S3 PutObject actions
96+
event.dataset == "aws.cloudtrail"
97+
and event.provider == "s3.amazonaws.com"
98+
and event.action in ("GetObject","PutObject")
99+
100+
// filter for IAM users, not federated identities
101+
and aws.cloudtrail.user_identity.type in ("IAMUser", "AssumedRole")
102+
103+
// filter for S3 static site bucket paths from webpack or similar
104+
and aws.cloudtrail.request_parameters LIKE "*static/js/*.js*"
105+
106+
// exclude common IaC tools and automation scripts
107+
and not (
108+
user_agent.original LIKE "*Terraform*"
109+
or user_agent.original LIKE "*Ansible*"
110+
or user_agent.original LIKE "*Pulumni*"
111+
)
112+
113+
// extract bucket and object details from request parameters
114+
| dissect aws.cloudtrail.request_parameters "%{{?bucket.name.key}=%{bucket.name}, %{?host.key}=%{bucket.host}, %{?bucket.object.location.key}=%{bucket.object.location}}"
115+
116+
// filter for specific bucket and object structure
117+
| dissect bucket.object.location "%{}static/js/%{bucket.object}"
118+
119+
// filter for JavaScript files
120+
| where ENDS_WITH(bucket.object, ".js")
121+
| keep
122+
aws.cloudtrail.user_identity.arn,
123+
aws.cloudtrail.user_identity.access_key_id,
124+
aws.cloudtrail.user_identity.type,
125+
aws.cloudtrail.request_parameters,
126+
bucket.name,
127+
bucket.object,
128+
user_agent.original,
129+
source.ip,
130+
event.action,
131+
@timestamp
132+
133+
----------------------------------
134+
135+
*Framework*: MITRE ATT&CK^TM^
136+
137+
* Tactic:
138+
** Name: Impact
139+
** ID: TA0040
140+
** Reference URL: https://attack.mitre.org/tactics/TA0040/
141+
* Technique:
142+
** Name: Data Manipulation
143+
** ID: T1565
144+
** Reference URL: https://attack.mitre.org/techniques/T1565/
145+
* Sub-technique:
146+
** Name: Stored Data Manipulation
147+
** ID: T1565.001
148+
** Reference URL: https://attack.mitre.org/techniques/T1565/001/

0 commit comments

Comments
 (0)