Skip to content

Commit 2d7ce47

Browse files
committed
chore: add ro-dc default selector
1 parent 3dd2256 commit 2d7ce47

File tree

1 file changed

+45
-0
lines changed
  • cmd/api/src/database/migration/migrations

1 file changed

+45
-0
lines changed

cmd/api/src/database/migration/migrations/v7.6.0.sql

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,48 @@ INSERT INTO parameters (key, name, description, value, created_at, updated_at) V
2525

2626
-- Add Auth Session TTL Hours
2727
INSERT INTO parameters (key, name, description, value, created_at, updated_at) VALUES ('auth.session_ttl_hours', 'Auth Session TTL Hours', 'This configuration parameter determines the length of time in hours a logged in session stays active before expiration.', '{"hours": 8}', current_timestamp, current_timestamp) ON CONFLICT DO NOTHING;
28+
29+
-- Add RO-DC default selector to Tier Zero
30+
WITH src_data AS (
31+
SELECT * FROM (VALUES
32+
-- START
33+
('Read-Only DCs', false, true, E'MATCH (n:Computer)\nWHERE n.isReadOnlyDC = true\nRETURN n;', E'An attacker with control over a RODC computer object can compromise Tier Zero principals. The attacker can modify the msDS-RevealOnDemandGroup and msDS-NeverRevealGroup attributes of the RODC computer object such that the RODC can retrieve the credentials of a targeted Tier Zero principal. The attacker can obtain admin access to the OS of the RODC through the managedBy attribute, from where they can obtain the credentials of the RODC krbtgt account. With that, the attacker can create a RODC golden ticket for the target principal. This ticket can be converted to a real golden ticket as the target has been added to the msDS-RevealOnDemandGroup attribute and is not protected by the msDS-NeverRevealGroup attribute. Therefore, the RODC computer object is Tier Zero.')
34+
-- END
35+
) AS s (name, enabled, allow_disable, cypher, description)
36+
), inserted_selectors AS (
37+
INSERT INTO asset_group_tag_selectors (
38+
asset_group_tag_id,
39+
created_at,
40+
created_by,
41+
updated_at,
42+
updated_by,
43+
disabled_at,
44+
disabled_by,
45+
name,
46+
description,
47+
is_default,
48+
allow_disable,
49+
auto_certify
50+
)
51+
SELECT
52+
(SELECT id FROM asset_group_tags WHERE type = 1 and position = 1),
53+
current_timestamp,
54+
'SYSTEM',
55+
current_timestamp,
56+
'SYSTEM',
57+
CASE WHEN NOT d.enabled THEN current_timestamp ELSE NULL END,
58+
CASE WHEN NOT d.enabled THEN 'SYSTEM' ELSE NULL END,
59+
d.name,
60+
d.description,
61+
true,
62+
d.allow_disable,
63+
false
64+
FROM src_data d WHERE NOT EXISTS(SELECT 1 FROM asset_group_tag_selectors WHERE name = d.name)
65+
RETURNING id, name
66+
)
67+
INSERT INTO asset_group_tag_selector_seeds (selector_id, type, value)
68+
SELECT
69+
s.id,
70+
2,
71+
d.cypher
72+
FROM inserted_selectors s JOIN src_data d ON d.name = s.name;

0 commit comments

Comments
 (0)