Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat(insights): leave project admins out of exposure counts, the score and the graph

Dimitris Staratzisbf678d27a0ed
diff --git a/backend/CLAUDE.md b/backend/CLAUDE.md
index d1cb2edd48..d49c32136c 100644
--- a/backend/CLAUDE.md
+++ b/backend/CLAUDE.md
@@ -1149,7 +1149,8 @@ owns the two read endpoints and hands `recordRead` / `recordBulkRead` through to
access change restarts the window, including an edit to the rules of a custom role the reader holds. The per-secret sheet
shows the plain fact instead: a read, or "No reads". Each card row also carries three counts for its secret,
derived from sets the computation already holds: `entitledCount` (everyone who can read the value today,
- admins included), `unreadCount` (the non-admins among them with no read in the window) and
+ project admins left out, since a secret is not exposed to someone who can read everything by design),
+ `unreadCount` (those among them with no read in the window) and
`ghostReaderCount` (readers in the window who can no longer read it, so they still know the value).
- **Exposure score.** `calculateExposureScore` (`secret-read-activity-fns.ts`) turns those three counts into a 0
to 100 score with Low, Elevated, High and Critical bands and whole-point drivers that add up to it (readers up
diff --git a/backend/src/ee/services/secret-read-activity/secret-read-activity-service.ts b/backend/src/ee/services/secret-read-activity/secret-read-activity-service.ts
index aa949ab5a5..d9ae6ed3a0 100644
--- a/backend/src/ee/services/secret-read-activity/secret-read-activity-service.ts
+++ b/backend/src/ee/services/secret-read-activity/secret-read-activity-service.ts
@@ -305,19 +305,24 @@ export const secretReadActivityServiceFactory = ({
)
.flat();
const entitledKeys = new Set(entitled.map((actor) => `${actor.actorType}:${actor.id}`));
- const unread = entitled.filter(
+ // Admins can read everything by design, so a secret is not exposed to them: they are left out of the counts and
+ // the score, though their reads still show, and a read of theirs is never a ghost's.
+ const exposedTo = entitled.filter((actor) => !adminActorIds.has(actor.id));
+ const unread = exposedTo.filter(
(actor) =>
- !adminActorIds.has(actor.id) &&
!reads.has(`${actor.actorType}:${actor.id}`) &&
coversWholeWindow(trackedSince, accessChangedAtByActorId.get(actor.id), judgedFrom)
);
- const ghostReaders = [...reads.values()].filter((read) => !entitledKeys.has(`${read.actorType}:${read.actorId}`));
+ const ghostReaders = [...reads.values()].filter(
+ (read) => !entitledKeys.has(`${read.actorType}:${read.actorId}`) && !adminActorIds.has(read.actorId)
+ );
return {
entitled,
+ exposedTo,
unread,
ghostReaders,
exposure: calculateExposureScore(
- { entitledCount: entitled.length, unreadCount: unread.length, ghostReaderCount: ghostReaders.length },
+ { entitledCount: exposedTo.length, unreadCount: unread.length, ghostReaderCount: ghostReaders.length },
trackedDays
)
};
@@ -364,7 +369,7 @@ export const secretReadActivityServiceFactory = ({
message: `Secret with name '${secretName}' not found at path '${secretPath}' in environment '${environment}'`
});
}
- const { entitled, unread, ghostReaders, exposure } = summarize(activity);
+ const { entitled, exposedTo, unread, ghostReaders, exposure } = summarize(activity);
const unreadKeys = new Set(unread.map((reader) => `${reader.actorType}:${reader.id}`));
// A ghost reader may have left the project or been deleted since, so names the project's members do not
@@ -393,7 +398,7 @@ export const secretReadActivityServiceFactory = ({
accessChangedAt: accessChangedAtByActorId.get(reader.id) ?? null
})
),
- entitledCount: entitled.length,
+ entitledCount: exposedTo.length,
unreadCount: unread.length,
ghostReaderCount: ghostReaders.length,
exposure,
@@ -421,10 +426,10 @@ export const secretReadActivityServiceFactory = ({
await new Promise<void>((resolve) => {
setImmediate(resolve);
});
- const { entitled, unread, ghostReaders, exposure } = summarize(activities[activityIndex]);
+ const { exposedTo, unread, ghostReaders, exposure } = summarize(activities[activityIndex]);
summaries.push({
activityIndex,
- entitledCount: entitled.length,
+ entitledCount: exposedTo.length,
unreadCount: unread.length,
ghostReaderCount: ghostReaders.length,
score: exposure.score
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts
index c31e09383f..021440bef4 100644
--- a/backend/src/lib/api-docs/constants.ts
+++ b/backend/src/lib/api-docs/constants.ts
@@ -1402,8 +1402,9 @@ export const SECRET_EXPOSURE = {
"Which term the driver is: readers (up to 45 points), ghost-readers (up to 30 points) or unused-access (up to 25 points).",
driverPoints: "The whole points this term contributed to the score.",
driverLabel: "The term in words, with its counts.",
- entitledCount: "How many users and machine identities, admins included, can read this secret's value today.",
- unreadCount: "How many of those, admins excluded, have not read it in the last 30 days.",
+ entitledCount:
+ "How many users and machine identities can read this secret's value today. Project admins are left out: they can read everything by design, so the secret is not exposed to them.",
+ unreadCount: "How many of those have not read it in the tracked period, up to the last 30 days.",
ghostReaderCount:
"How many users and machine identities read this secret in the last 30 days but can no longer read it today, for example after leaving the project. They still know the value."
};
@@ -1502,7 +1503,7 @@ export const RAW_SECRETS = {
judgedFrom:
"The start of the period unused access is judged on: the later of 30 days ago and when read tracking began for the project. A reader only counts as unused access once the secret and their access both predate it.",
entitled:
- "One entry for each user or machine identity that can read the secret's value today, admins included, saying whether they count as unused access and, if not, why.",
+ "One entry for each user or machine identity that can read the secret's value today, project admins included so their reads can be shown, saying whether they count as unused access and, if not, why.",
unread:
"Whether the reader counts as unused access: no read since trackedSince, with the secret and their access both older than judgedFrom.",
isAdmin:
diff --git a/frontend/src/components/secrets/SecretExposureScore.tsx b/frontend/src/components/secrets/SecretExposureScore.tsx
index 649555b5bf..371b841415 100644
--- a/frontend/src/components/secrets/SecretExposureScore.tsx
+++ b/frontend/src/components/secrets/SecretExposureScore.tsx
@@ -134,9 +134,9 @@ export const SecretExposurePanel = ({ exposure, className }: PanelProps) => {
<p className="text-xs text-accent">Nobody can read this secret&apos;s value.</p>
)}
<p className="text-xs text-muted">
- Up to 45 points for how many can read the value, 30 for ghost readers who still know it,
- and 25 for the share who have not read it in the tracked period, which counts in full once
- that period is 30 days.
+ Up to 45 points for how many can read the value (project admins aside), 30 for ghost
+ readers who still know it, and 25 for the share who have not read it in the tracked
+ period, which counts in full once that period is 30 days.
</p>
</div>
</div>
diff --git a/frontend/src/pages/secret-manager/InsightsPage/components/SecretExposureCard.tsx b/frontend/src/pages/secret-manager/InsightsPage/components/SecretExposureCard.tsx
index b3dd472d40..62ecfb4ff7 100644
--- a/frontend/src/pages/secret-manager/InsightsPage/components/SecretExposureCard.tsx
+++ b/frontend/src/pages/secret-manager/InsightsPage/components/SecretExposureCard.tsx
@@ -167,7 +167,9 @@ export const SecretExposureCard = () => {
<Empty className="border">
<EmptyHeader>
<EmptyTitle>No exposed secrets</EmptyTitle>
- <EmptyDescription>A secret scores once someone can read its value.</EmptyDescription>
+ <EmptyDescription>
+ A secret scores once someone other than a project admin can read its value.
+ </EmptyDescription>
</EmptyHeader>
</Empty>
) : (
@@ -247,8 +249,8 @@ export const SecretExposureCard = () => {
<span>{row.entitledCount}</span>
</TooltipTrigger>
<TooltipContent>
- {row.entitledCount} users and machine identities, admins included, can
- read this secret&apos;s value
+ {row.entitledCount} users and machine identities, project admins aside,
+ can read this secret&apos;s value
</TooltipContent>
</Tooltip>
</TableCell>
@@ -261,7 +263,7 @@ export const SecretExposureCard = () => {
</TooltipTrigger>
<TooltipContent>
{row.unreadCount} of the {row.entitledCount} who can read this secret,
- project admins aside, have not read it {readPeriod}
+ have not read it {readPeriod}
</TooltipContent>
</Tooltip>
</TableCell>
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretAccessInsights.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretAccessInsights.tsx
index 01c5eeb5a3..5660f9203d 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretAccessInsights.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretAccessInsights.tsx
@@ -573,6 +573,8 @@ export function SecretAccessInsights({
.filter((group) => group[memberField].includes(entry.id))
.map((group) => group.id);
if (!isDirect && !groupIds.length) return [];
+ // Admins can read everything by design, so the secret is not exposed to them and they stay off the graph.
+ if (entitledReaders.get(`${type}:${entry.id}`)?.isAdmin) return [];
const status = readStatusOf(type, entry.id);
return [
{