Skip to content

[MNGSITE-503] add .well-known/security.txt - #354

Merged
bmarwell merged 4 commits into
masterfrom
MNGSITE-503_security.txt
Dec 11, 2022
Merged

bmarwell merged 4 commits into
masterfrom
MNGSITE-503_security.txt

Conversation

@bmarwell

@bmarwell bmarwell commented Dec 9, 2022 •

Copy link
Copy Markdown
Contributor

Comment thread pom.xml Resolved
Comment thread pom.xml Resolved
Comment thread pom.xml Resolved
Comment thread pom.xml Resolved
@bmarwell
bmarwell force-pushed the MNGSITE-503_security.txt branch from 8fd1fb4 to 350e7ab Compare December 10, 2022 12:26
@bmarwell

bmarwell commented Dec 10, 2022 •

Copy link
Copy Markdown
Contributor Author

@michael-o now we have this:

[INFO] --- build-helper-maven-plugin:3.3.0:timestamp-property (create-security.txt-timestamp) @ maven-site ---
[WARNING] Using platform locale (en_US actually) to format date/time, i.e. build is platform dependent!

I still suggest adding root or to explicitly set <locale>ROOT</locale>.

@bmarwell
bmarwell requested a review from michael-o December 10, 2022 12:30

@michael-o michael-o left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two issues:

@bmarwell

Copy link
Copy Markdown
Contributor Author

Two issues:

Huh. It's manual work and highly likely it's forgotten. It's very likely that

  • We push this project at least once or twice a year
  • The project is being maintained (or at least reachable) about 12 months after pushing out the last release.

-1 for a fixed date.

  • It doesn't add any value
  • Can easily be forgotten
  • Needs extra pushes/releases.

The special variable doesn't work with offsets. And I fail to see how this would help. The expiry format MUST BE an ISO 8601 timestamp.

@bmarwell

Copy link
Copy Markdown
Contributor Author

Removing the locale now leads to a warning that the build is system dependent. Is this really wanted? I feel having warnings intentionally seems odd. This might get "fixed" by someone else in the future who didn't read this thread.

@michael-o

Copy link
Copy Markdown
Member

@bmarwell I have added a commit which does it right. No fuzz, no additonal plugins. WFM:

Contact: mailto:[email protected]
Contact: mailto:[email protected]
Expires: 2022-12-10T18:48:02Z
Preferred-Languages: en
Policy: https://www.apache.org/security/
Policy: https://maven.apache.org/security.html

@bmarwell

bmarwell commented Dec 10, 2022 •

Copy link
Copy Markdown
Contributor Author

So you are uploading an expired file. Expires MUST be in the future!

The date and time when the content of the security.txt file should be considered stale (so security researchers should then not trust it). Make sure you update this value periodically and keep your file under review.

https://www.rfc-editor.org/rfc/rfc9116#section-2.5.5

Will undo the commit tomorrow if you don't.

@michael-o

michael-o commented Dec 10, 2022 •

Copy link
Copy Markdown
Member

So you are uploading an expired file. Expires MUST be in the future!

Oh man, I am so stupid. You are right, of course. I left this out completely. I guess I should not code anymore today. But still, having the date being set automatically, I consider wrong because the provided information must be manually reviewed.

Please drop the commit.

@michael-o

Copy link
Copy Markdown
Member

I just have reported a bug in RFC 9116. Quite embarassing one.

@asfgit
asfgit force-pushed the MNGSITE-503_security.txt branch from d80151d to 350e7ab Compare December 10, 2022 19:11
@michael-o

michael-o commented Dec 10, 2022 •

Copy link
Copy Markdown
Member

@michael-o now we have this:

[INFO] --- build-helper-maven-plugin:3.3.0:timestamp-property (create-security.txt-timestamp) @ maven-site ---
[WARNING] Using platform locale (en_US actually) to format date/time, i.e. build is platform dependent!

I still suggest adding root or to explicitly set <locale>ROOT</locale>.

This does not work. Again, providing <locale>ROOT</locale> will not give you Locale#ROOT. Look at the code. There is no handling for this. All it will give you is new Locale("root") which does not exist and is wrong. You need something like this to handle the literal ROOT.

@bmarwell

Copy link
Copy Markdown
Contributor Author

@michael-o now we have this:

[INFO] --- build-helper-maven-plugin:3.3.0:timestamp-property (create-security.txt-timestamp) @ maven-site ---
[WARNING] Using platform locale (en_US actually) to format date/time, i.e. build is platform dependent!

I still suggest adding root or to explicitly set <locale>ROOT</locale>.

This does not work. Again, providing <locale>ROOT</locale> will not give you Locale#ROOT. Look at the code. There is no handling for this. All it will give you is new Locale("root") which does not exist and is wrong. You need something like this to handle the literal ROOT.

I did and I ran it and it worked as expected for me. Minus one hour (I live in Europe/Berlin).

Code path:

Locale locale;
         if ( this.locale != null )
        {
            String[] bits = this.locale.split( "[,_]" );
            if ( bits.length == 1 )
            {
                 locale = new Locale( bits[0].trim() );
            }

It splits "ROOT" wich returns length 1 and Will just pass it though.

I still don't know how you think it's going to be lower case.

As an alternative, we can pass in

<locale>${user.lang}_${user.country}</locale>

...which is the same, but just explicit.

@michael-o

Copy link
Copy Markdown
Member

@michael-o now we have this:

[INFO] --- build-helper-maven-plugin:3.3.0:timestamp-property (create-security.txt-timestamp) @ maven-site ---
[WARNING] Using platform locale (en_US actually) to format date/time, i.e. build is platform dependent!

I still suggest adding root or to explicitly set <locale>ROOT</locale>.

This does not work. Again, providing <locale>ROOT</locale> will not give you Locale#ROOT. Look at the code. There is no handling for this. All it will give you is new Locale("root") which does not exist and is wrong. You need something like this to handle the literal ROOT.

I did and I ran it and it worked as expected for me. Minus one hour (I live in Europe/Berlin).

Code path:

Locale locale;
         if ( this.locale != null )
        {
            String[] bits = this.locale.split( "[,_]" );
            if ( bits.length == 1 )
            {
                 locale = new Locale( bits[0].trim() );
            }

It splits "ROOT" wich returns length 1 and Will just pass it though.

I still don't know how you think it's going to be lower case.

As an alternative, we can pass in

<locale>${user.lang}_${user.country}</locale>

...which is the same, but just explicit.

Read the specs of the Locale constructor and what Locale#ROOT is. You are misunderstanding the behavior. It does not give you what you expect.

@bmarwell

Copy link
Copy Markdown
Contributor Author

I still don't believe it matters as the format string does not contain any locale-specific patterns.
But if you insist, why not use the Maven properties I suggested?

@michael-o

Copy link
Copy Markdown
Member

Plexus XML handling coerces both: <locale> </locale> and <locale></locale> to null instead of "" which is actually what you want/need. The only way to fix this is to do "ROOT".equals(this.locale)...locale = Locale.ROOT.

@michael-o

Copy link
Copy Markdown
Member

I still don't believe it matters as the format string does not contain any locale-specific patterns. But if you insist, why not use the Maven properties I suggested?

I did not say that it does matter, all I am telling is that <locale /> does not behave the way you assume. Since we cannot really request Locale#ROOT I would use a really non-existing value and document it as such, e.g. BOGUS.

@michael-o

Copy link
Copy Markdown
Member

@kwin I know that you have been working on this Plexus non-sense with trimming and to null coercion. Do you remember by any chance why an empty string is coerced to null?

@michael-o

michael-o commented Dec 10, 2022 •

Copy link
Copy Markdown
Member

@bmarwell This is what you were looking for:

diff --git a/pom.xml b/pom.xml
index a7d46e96..8686e1e1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -251,6 +251,8 @@
             <configuration>
               <name>maven.security.expires</name>
               <pattern>yyyy-MM-dd'T'HH:mm:ssXXX</pattern>
+              <!-- This ulgy Plexus magic will be coerced in the plugin to Locale#ROOT -->
+              <locale xml:space="preserve"> </locale>
               <offset>+1</offset>
               <unit>year</unit>
             </configuration>

@michael-o

Copy link
Copy Markdown
Member

Here it is: https://issues.apache.org/jira/browse/MNG-6434

Comment thread pom.xml Resolved

@slawekjaranowski slawekjaranowski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple file and such long discussion.

Expire should be updated automatically - no one will remember to update it.

I'm not sure how many researcher will use it,
simply we can try put it and will observe if it helps for security issues generated by boots

@hboutemy

hboutemy commented Dec 11, 2022 •

Copy link
Copy Markdown
Member

one idea: shouldn't we simplify with

<pattern>yyyy-MM-'01T00:00:00Z'</pattern>

ie just round to month, and forget about all the details for locale?

that would match the spirit of having an automatic date, but without having it changed too much: once per month, not every rebuild (then no noise at svnpubsub level on each build)

WDYT?

@michael-o

Copy link
Copy Markdown
Member

one idea: shouldn't we simplify with

<pattern>yyyy-MM-'01T00:00:00Z'</pattern>

ie just round to month, and forget about all the details for locale?

that would match the spirit of having an automatic date, but without having it changed too much: once per month, not every rebuild (then no noise at svnpubsub level on each build)

WDYT?

Then just drop to date only. Fully valid ISO date

@bmarwell

Copy link
Copy Markdown
Contributor Author

Then just drop to date only. Fully valid ISO date

Spec explicitly asks for date and TIME.

+1 for Hervés suggestion, will add later.

@michael-o

michael-o commented Dec 11, 2022 •

Copy link
Copy Markdown
Member

Then just drop to date only. Fully valid ISO date

Spec explicitly asks for date and TIME.

+1 for Hervés suggestion, will add later.

https://www.rfc-editor.org/rfc/rfc9116#section-2.5.5 does not say that. It just says that the format has to comply with ISO 8601. Moreover, the example is invalid according to ISO 8601 and this I wrote Yakov yesterday. Unless it uses the word MUST a local date is more than enough. Everything else is a problem with the RFC itself.

yyyy-MM-dd is just enough.

@bmarwell

Copy link
Copy Markdown
Contributor Author

So, a researcher in the US gets more time. Interesting!

Tbh I think only an instant makes sense to avoid this. Probably all scanners try to parse a time and "Z". It doesn't even hurt.

@bmarwell

bmarwell commented Dec 11, 2022 •

Copy link
Copy Markdown
Contributor Author

When I open the RFC it clearly says

The "Expires" field indicates the date and time[...]

and

The value of this field is formatted according to[...]

I think it couldn't be more clear. They require date and time in the format defined in 8601. While 8601 also defines LocalDate, in this case they want a DateTimeInstant defined how 8601 would want to have it.

@michael-o

Copy link
Copy Markdown
Member

When I open the RFC it clearly says

The "Expires" field indicates the date and time[...]

and

The value of this field is formatted according to[...]

I think it couldn't be more clear. They require date and time in the format defined in 8601. While 8601 also defines LocalDate, in this case they want a DateTimeInstant defined how 8601 would want to have it.

This is not what I understand. The specification is not concrete enough for me. A telescoping approach should be fine otherwise an erratum is necessary.

@bmarwell

Copy link
Copy Markdown
Contributor Author

This is not what I understand. The specification is not concrete enough for me.

That's a legit statement. However, it could take some considerable amount of time until the issue you opened has been resolved (i.e. clarification and fix of the example). As @bdemers, @hboutemy and @slawekjaranowski are okay with the state as-is, let’s merge it and come back later if it needs attention.

@michael-o
michael-o self-requested a review December 11, 2022 20:57

@michael-o michael-o left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make it really explicit I would add <timeZone>Etc/UTC</timeZone> to show our intent. The rest is fine now.

@bmarwell
bmarwell force-pushed the MNGSITE-503_security.txt branch from 2ca7b80 to c6bb375 Compare December 11, 2022 21:13
@bmarwell
bmarwell force-pushed the MNGSITE-503_security.txt branch from c6bb375 to 05bbfc0 Compare December 11, 2022 21:16
@bmarwell
bmarwell merged commit 41383fd into master Dec 11, 2022
@bmarwell
bmarwell deleted the MNGSITE-503_security.txt branch December 11, 2022 21:35
@jira-importer

Copy link
Copy Markdown

Resolve #1095

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants