-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Fix IFC private repository labels #2695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
RossTarrant
wants to merge
1
commit into
main
Choose a base branch
from
rosstarrant/fix-ifc-private-labels
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+136
−119
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -76,10 +76,23 @@ func LabelGetMe() SecurityLabel { | |||||
| // LabelListIssues returns the IFC label for a list_issues result. | ||||||
| // Public repositories are universally readable; private repositories are | ||||||
| // restricted to their collaborators (resolved client-side from the marker). | ||||||
| // Issue contents are attacker-controllable, so integrity is always untrusted. | ||||||
| // Public repository issue contents are attacker-controllable, while private | ||||||
| // repository issues are treated as trusted collaborator-authored data. | ||||||
| func LabelListIssues(isPrivate bool) SecurityLabel { | ||||||
| if isPrivate { | ||||||
| return PrivateUntrusted() | ||||||
| return PrivateTrusted() | ||||||
|
RossTarrant marked this conversation as resolved.
|
||||||
| } | ||||||
| return PublicUntrusted() | ||||||
| } | ||||||
|
|
||||||
| // LabelRepoUserContent returns the IFC label for user-authored content scoped | ||||||
| // to a repository when that tool has not opted into a more specific integrity | ||||||
| // policy. Public repository content is untrusted because it may be authored by | ||||||
| // outside contributors. Private repository content is trusted because users who | ||||||
| // can read it are trusted collaborators. | ||||||
| func LabelRepoUserContent(isPrivate bool) SecurityLabel { | ||||||
| if isPrivate { | ||||||
| return PrivateTrusted() | ||||||
| } | ||||||
| return PublicUntrusted() | ||||||
| } | ||||||
|
|
@@ -99,11 +112,12 @@ func LabelGetFileContents(isPrivate bool) SecurityLabel { | |||||
| // result, joining per-repository labels across all matched repositories. | ||||||
| // Used by both search_issues and search_repositories. | ||||||
| // | ||||||
| // Integrity is always untrusted because results expose user-authored content. | ||||||
| // | ||||||
| // Confidentiality follows the IFC meet (greatest lower bound): if any matched | ||||||
| // repository is private the joined label is private; otherwise public. The | ||||||
| // reader set is opaque (the "private" marker); the client engine resolves | ||||||
| // Public-only results are untrusted and public. All-private results are trusted | ||||||
| // and private because private repository content is treated as trusted | ||||||
| // collaborator-authored data. Mixed public/private results are untrusted and | ||||||
| // private: the public items keep the joined payload's integrity untrusted, | ||||||
| // while the private items keep the joined payload's confidentiality private. | ||||||
| // The reader set is opaque (the "private" marker); the client engine resolves | ||||||
| // concrete readers on demand at egress decision time. | ||||||
| // | ||||||
| // An empty result set is treated as public-untrusted (no repository data is | ||||||
|
|
@@ -119,12 +133,22 @@ func LabelGetFileContents(isPrivate bool) SecurityLabel { | |||||
| // until then they would invite unsafe declassification of a "public" item that | ||||||
| // actually arrived alongside private data. | ||||||
| func LabelSearchIssues(repoVisibilities []bool) SecurityLabel { | ||||||
| var anyPrivate, anyPublic bool | ||||||
| for _, isPrivate := range repoVisibilities { | ||||||
| if isPrivate { | ||||||
| return PrivateUntrusted() | ||||||
| anyPrivate = true | ||||||
| } else { | ||||||
| anyPublic = true | ||||||
| } | ||||||
|
RossTarrant marked this conversation as resolved.
|
||||||
| } | ||||||
| return PublicUntrusted() | ||||||
| switch { | ||||||
| case anyPrivate && anyPublic: | ||||||
| return PrivateUntrusted() | ||||||
| case anyPrivate: | ||||||
| return PrivateTrusted() | ||||||
| default: | ||||||
| return PublicUntrusted() | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| // LabelRepoMetadata returns the IFC label for structural repository metadata | ||||||
|
|
@@ -261,32 +285,21 @@ func LabelRepositorySecurityAdvisory(isPrivate bool, allPublished bool) Security | |||||
| // LabelGist returns the IFC label for gist content. | ||||||
| // | ||||||
| // Integrity is untrusted: gist contents are arbitrary user-authored text. | ||||||
| // Confidentiality derives from the gist's own visibility rather than any | ||||||
| // repository — public gists are universally readable, while secret gists are | ||||||
| // restricted to those who hold the gist URL (modeled with the opaque "private" | ||||||
| // marker). | ||||||
| func LabelGist(isPublic bool) SecurityLabel { | ||||||
| if isPublic { | ||||||
| return PublicUntrusted() | ||||||
| } | ||||||
| return PrivateUntrusted() | ||||||
| // Confidentiality is public because secret gists are URL-accessible and cannot | ||||||
| // be modeled as private to a GitHub reader set. | ||||||
| func LabelGist() SecurityLabel { | ||||||
| return PublicUntrusted() | ||||||
| } | ||||||
|
|
||||||
| // LabelGistList returns the IFC label for a list of gists belonging to a user, | ||||||
| // joining the per-gist confidentiality across the result set. | ||||||
| // | ||||||
| // Integrity is untrusted (user-authored content). Confidentiality follows the | ||||||
| // IFC meet: if any gist in the result is secret the joined label is private; | ||||||
| // otherwise public. An empty result is treated as public-untrusted. | ||||||
| // Integrity is untrusted (user-authored content). Confidentiality is public | ||||||
| // because even secret gists are URL-accessible. | ||||||
| // | ||||||
| // See LabelSearchIssues for why list results carry a single joined label | ||||||
| // rather than one label per item. | ||||||
| func LabelGistList(gistVisibilities []bool) SecurityLabel { | ||||||
| for _, isPublic := range gistVisibilities { | ||||||
| if !isPublic { | ||||||
| return PrivateUntrusted() | ||||||
| } | ||||||
| } | ||||||
| func LabelGistList() SecurityLabel { | ||||||
| return PublicUntrusted() | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -295,13 +308,13 @@ func LabelGistList(gistVisibilities []bool) SecurityLabel { | |||||
| // | ||||||
| // Integrity is untrusted: project titles, item content, and status update | ||||||
| // bodies are user-authored free text. Confidentiality derives from the | ||||||
| // project's own public flag — public projects are universally readable, while | ||||||
| // private projects restrict the reader set. | ||||||
| func LabelProject(isPublic bool) SecurityLabel { | ||||||
| if isPublic { | ||||||
| return PublicUntrusted() | ||||||
| // project's own privacy — private projects restrict the reader set, while | ||||||
| // public projects are universally readable. | ||||||
| func LabelProject(isPrivate bool) SecurityLabel { | ||||||
| if isPrivate { | ||||||
| return PrivateUntrusted() | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| } | ||||||
| return PrivateUntrusted() | ||||||
| return PublicUntrusted() | ||||||
| } | ||||||
|
|
||||||
| // LabelTeam returns the IFC label for organization team membership data | ||||||
|
|
||||||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.